tags:

views:

539

answers:

9

I've recently started to learn C++ and am completely confused with the choices of IDEs and compilers out there. I am competent with interpreted languages and like the simplicity of using any IDE or text editor and then running the interpreter from the command line. Everything works as I expect, regardless of the IDE used, because I use the same interpreter each time.

Now that I have started learning C++ I am overwhelmed by the choice of different compilers and more importantly, their differences. It seems that things will be simpler for me (not necessarily easier) if, while learning, I use a text editor and a compiler that I run from the command line. I have a basic understanding of how compiling and linking works and I understand the role of header files.

Firstly, are there any books or websites that teach C++ from this approach? (IDE-less) Many books try to point out the differences between IDEs and compilers by selecting two and comparing them, which confuses me.

Secondly, how should I set up my workflow? (Ignore the choice of text editor, I am talking about compilers, linkers etc.) I am struggling to understand what differences different compilers have and so please bear this in mind when answering. It seems like the most popular compilers are g++ and CL. Similar question but I am more interested in why some programs will work with some compilers and not others: http://stackoverflow.com/questions/958695/c-compiler-for-windows-without-ide

Further information: I am developing on Windows and from what I understand, it seems that there is 'pure' C++ and then C++ that is somehow related to windows, is this Visual C++? I would like to write programs that make use of Windows features but I want to know when I am using windows features and when I am writting code that would work on any platform.

Update: So it seems that I shouldn't be worrying about compilers when I am just starting out. The reason for me wanting to understand the differences is because I don't want to write code for a specific compiler and get into bad habits. Is this a non-issue?

+4  A: 

Use MinGW - it's a command-line C++ development toolchain that allows you create Windows applications. The SO link you quoted seems to have all the relevant details, so I don't really understand why you posted this question.

anon
You are asking the wrong question, and one that really can't be answered. They are both implementations of the same language standard. In som,e areas one will be a little better at implementing tjhose standards than the other. But you should not be worrying about such things at this stage.
anon
Ok thanks. I find it hard not to be worrying about these things however because I find that some code will compile with one compiler and not another which confuses me when I am trying to lean even the basics.
Pheter
When it comes to the basics, both compilers support the same language features.
anon
Alright then, it sounds like MinGW is what I am after. I appreciate your help.
Pheter
+3  A: 

Firstly, are there any books or websites that teach C++ from this approach? (IDE-less)

Start from reading The C++ Programming Language book. Written by Bjarne Stroustrup, the creator of C++, this is the world's most trusted and widely read book on C++.

Take a look also at Programming — Principles and Practice Using C++. It is an introduction to programming for people who has never programmed before. It will also be useful for people who have programmed a bit and want to improve their style and technique - or simply learn modern C++.

Kirill V. Lyadvinsky
But unfortunately not the best one for learning C++.
anon
May be not for beginners in programming, but the best for beginners in C++.
Kirill V. Lyadvinsky
@Neil: Can you elaborate on your opinions about Stroustrup's programming introduction book? I haven't looked at it yet, but having taught C++ for years, I'm very interested in it.
sbi
TC++PL is one of the definitive book on C++. However it's very terse, so not the best thing for someone with little experience with C++ and or programming in general.
KTC
I think that Neil was talking about the first book. Programming introduction book I've added after his comment.
Kirill V. Lyadvinsky
Yes, I was talking about TC++PL - I haven't read the other one.
anon
Ah, sorry for the confusion.
sbi
+1  A: 

I am developing on Windows and from what I understand, it seems that there is 'pure' C++ and then C++ that is somehow related to windows, is this Visual C++? I would like to write programs that make use of Windows features but I want to know when I am using windows features and when I am writting code that would work on any platform.

MS Visual C++ 2008 Express is a free IDE aimed at folks like you, it's available by download from Microsoft, I recommend you try it out.

Maciek
Ok, I already have a copy of it installed but fear that I will start writing programs that make use of visual c++ features without realising that I am doing so, and therefore the program will not compile with anything but CL.
Pheter
@Pheter: That's always a problem, not only with VC, although I agree that it might be worse with VC than with, say, GCC. The only way to avoid this is to use more than one compiler. There's no harm in asking for several opinions.
sbi
In that case I will probably use MinGW and have a copy of CL ready for compiling a second time to ensure that things compile correctly in both. Thanks!
Pheter
Also, in response to myself: "is this Visual C++?" It is C++/CLI.
Pheter
The Visual C++ features are being stripped from Visual Studio 2008 Express namely MFC and ATL. See my comment on a similar topic http://stackoverflow.com/questions/1089437/learning-c-from-scratch-in-visual-studio/1090520#1090520
Cristian Adam
@Pheter: Using Visual C++ (7.1 or later) still allows you to use standard C++.
Cătălin Pitiș
When you create a new solution/project in VS C++ you get the option to create a totally empty project. No precompiled headers, not ATL no nothing. It's up to you what you wish to have in there.
Maciek
Using MS Visual C++ 2008 will allow you to write programs that make use of Windows features.
Partial
A: 

On Windows I'd recommend you Visual Studio Express - it's free and is widely accepted by C++ programmers on Windows platform.

Since you're starting to learn language, don't bother yourself with differences, advantages/disadvantages of compilers and IDEs - leave it when you'll be more proficient with the language and will be involved in writing real program.

dimba
A: 

I actually suggest IDE approach, Microsoft Visual C++ Express Edition should do the trick. Excluding some fancy syntax most C++ compilers behave the same way. C++ is a language that has a very small standard library (covering mostly I/O functions, basic math etc..) this is probably what you refer as pure C++. For something more advanced you'll have to use system libraries.. In example if you want to write windows gui application you'll have to include windows.h header file which is platform specific and exists only on windows compilers..

Ivan
Actually, it is a language with quite a large standard library, covering lots more than I/O - have you heard of the STL?
anon
It's in the etc part :) In my opinion it's still small standard library.. Most modern languages come with container libraries, and when you compare C++ standard library with that of .NET Framework, Java, or Python it really seams basic. Database, windowing, networking and threading support are all missing from standard C++ library..
Ivan
+1  A: 

Visual C++ is the name of the IDE program package. Installing it installs many things including the compiler cl.exe, which can compile, depending on settings, program written in either the C, C++, or C++/CLI programming language (for the .Net framework).

You can use the compiler on the command prompt without the IDE by (for example) selecting Start > Programs > Microsoft Visual Studio X > Visual Studio Tools > Visual Studio X Command Prompt. This execute a script which sets various environment settings needed to compile programs before giving you the command prompt.

KTC
+7  A: 

Firstly, are there any books or websites that teach C++ from this approach? (IDE-less)

Yes, definitely. Stroustrup's book has already been mentioned. For learning C++ I'd also recommend two other books: If you like thorough explanations and don't shy away from 1000 pages, look at Lippman et al. If you rather like a short introduction and don't fear a steep learning curve, look at Koenig/Moo. Both are excellent books. (BTW, a good place to look for good books has always been the book review section at the ACCU.)

As for which tool chain you want to use: If you rather have a standalone editor and invoke the compiler from the command line, you can do this with either GCC or VC. This approach has the advantage that it is more unlikely to lure you into using something proprietary (like C++/CLI). If you would like to try an IDE, VC Express is fine, once you're past setting up a new C++ project. Of course, the number of options you can tweak for a new project can be very overwhelming. But on the other hand you get things like an integrated debugger. Note that there are other integrated solutions, too. The most mature and prominent is probably eclipse.

Edit: If you don't mind spending a little money, look at Comeau. It's not free, but it's not expensive either and it's usually considered to be the most standard-conforming C++ compiler around and has excellent error messages. (You can test-drive it at the website.) Note that it emits C code, though. That means you have to have another compiler to create an executable program. But both GCC and VC Express will do, so there's no other cost. (Note that using VC you will get Dinkumware's std lib implementation, which is also considered to be a very good one.)

sbi
A: 

If you won't use an IDE, you definitely want to use Makefiles to organize your workflow... and you can make easily from emacs or vim.

Anyway, may I suggest you to use a very simple, almost non intrusive IDE, that could be great for learning purposes: http://www.bloodshed.net/devcpp.html

It comes with the MinGW compiler bundled, so it's just install and go.

fortran
Dev-C++ is abandonware, let's move on.... (i.e. at least use wxDev-C++ if you like that particular IDE interface.)
KTC
It's not about having the coolest interface or the latest features, I just pointed a tool where you write, press a button and the program compiles, press another button and it runs. And for that, devcpp is just enough, nothing more, nothing less... remember that the OP didn't want to mess with IDEs
fortran
DevC++ is no longer being developed and is buggy as hell. If he wants a non-MS IDE, he should use Code::Blocks.
anon
Dev-C++ looks like something that could suit me well as it offers just a basic level of funtionality. I have tried out MonoDevelop for windows (which probably isn't a good idea as it's an unstable version and therefore most likely isn't good for learning on) but it is my favourite environment so far. It does just what I need and no more (although, unfortunately, I couldn't get the debug working). Does anyone have any experience with MonoDevelop on windows?
Pheter
@Pheter ICSharpDevelop is a good replacement for MonoDevelop on Windows
fortran
@Pheter Do not consider DevC++ - the compiler is uses is ancient and may well cause the problems you were worrying about.
anon
A: 

I'd say to start out with Visual Studio. This is a great IDE for programming C++ on windows, might as well use it when it can speed up certain things a lot.

The differences between compilers aren't that huge - if you can write solid code in VS then it shouldn't be a problem to figure out how to get your code working in GCC/G++.

As for books; Exceptional C++ by Herb Sutter and The C++ Programming Language by Bjarne Stroustrup are a great read.

Visual Studio is the way to go when developing for Windows.

Chaoz