Learning C++ without an IDE

2020-05-20 07:39发布

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: 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?

9条回答
欢心
2楼-- · 2020-05-20 08:18

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.)

查看更多
\"骚年 ilove
3楼-- · 2020-05-20 08:18

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.

查看更多
我只想做你的唯一
4楼-- · 2020-05-20 08:21

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..

查看更多
甜甜的少女心
5楼-- · 2020-05-20 08:22

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++.

查看更多
叛逆
6楼-- · 2020-05-20 08:27

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.

查看更多
叼着烟拽天下
7楼-- · 2020-05-20 08:27

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.

查看更多
登录 后发表回答