开发者

Learning C++ on Linux or Windows? [closed]

开发者 https://www.devze.com 2022-12-09 15:31 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_JAVA技巧 Closed 9 years ago.

Since you 'should' learn C/C++ and as part of 'learn as much languages as possible', i decided to learn C++ in depth.

My OS is Windows and my question is should i re-install Linux as a dual boot to learn C++ on Linux?

Do i miss something if I develop in C++ only on the Windows platform?

(possible duplicate: https://stackoverflow.com/questions/1128050/best-operating-system-for-c-development-and-learning)


Doesn't really matter what platform you write your code on.

If you want to verify that your code is portable, you could install cygwin and gcc as well as visual studio.

Then you could compile with both compilers without having to dualboot


If your goal is simply to learn C++, it doesn't matter what platform you use because C++, as a general purpose programming language, is not platform-specific. You can learn standard C++ on any platform with a decent C++ compiler.


If you want to practice / test on Linux, you can simply create a virtual machine, for example with VirtualBox.


Do i miss something if I develop in C++ only on the Windows platform?

Valgrind.


Not really if you don't use OS specific calls or libs.

If you are asking about IDEs, compilers etc, that's a metter of your preferences about it.


First of all, learning "as many languges as possible" is less important than learning at least one programming language in depth first.

In my view, you should learn programming on the platform than you are most familiar with. If you are not familiar with Linux and it's features yet, it's no use to start learning programming with it because you wouldn't know what to do. You can also expect the MS documentation to be a bit more consistent than the Linux docs.

Some more things to consider:

  • You should get a ready-to-use development environment like Eclipe or MS Visual C++ (Windows). Getting the "standard way" with text editor, makefiles, etc. to work is too hard for a beginner, especially on Windows.
  • If you are going to use .NET on Windows, you have to be aware that the language is slightly different from standard C++. The same is true for C++ Builder, etc. If you are using Visual C++ or an environment based on the GNU compiler, you can program standard C++.
  • You should try to use C++ standard APIs and libraries like the STL, not MS-proprietary libs, except if you want to stick to Windows.


As long as you stick with cross-platform libraries (e.g. the C++ Standard Library, the Boost C++ Libraries, and the Qt Framework), instead of using platform-specific calls (e.g. the WIN32 API), and also assuming you use a cross-platform build system (e.g. CMake), instead of a platform-specific system (e.g. Visual Studio), then it won't matter. That said, it is much easier to setup a C/C++ development environment on Linux than it is to setup the equivalent development environment on Windows. And, since Linux will not include the "windows.h" header, you will be less likely to invoke Windows-specific features if you develop on Linux.


I recommend that you stick with Windows for a while until you gain some familiarity with the language. Then you can switch to Linux if you like. I say this because on Windows you can use Visual Studio (the Express Edition can be downloaded for free). Its user friendliness will ease some of the pain caused by the initial hurdles when learning C++.

Eventually you should also learn the Linux/Unix way by using gcc, makefiles and an advanced editor like vi/emacs/whatever.. However, this by itself is already challenging stuff, so save it for later and learn C++ first.


If, in the process of learning C and C++, you want to see how the libraries and the system actually work, Linux is the obvious choice as you can take a look at the system's entire source code.

IMHO, that can be quite instructive.


Since with C++ alone you will not be doing much, you should use both OSs (and more) to understand what is available to you in terms of libraries, compilers and IDEs (even development philosophies vary from OS to OS), this is not really important on your first steps into C++, at that stage it is more important which compiler/IDE you select...

Zed above rightly points you out the virtual machine option, VirtualBox is great.

Personally I would advise to avoid using Visual Studio as your first IDE/Compiler, it will add increased complexity and attempt to brainwash you into .net at every chance it gets. It will also make it hard for you later on to move to other setups...

Start with a simple text editor (Notepad++ on windows) and by using the command line for compilations.


Same question as I asked myself before started learning. That is should I have to have a dual boot? No. If you have installed VC++ with Visual studio you can use Visual Studio provided compiler and is easier to use also. Apart from this you can download and install Cygwin and make sure to check the gcc and its related components. You can launch CYGWIN just like your dos but it provides you UNIX environment to work with inside Windows environment. then just cd to the folder which contain .cpp, and compile using UNIX commands. Simple as that. Happy coding... (For the CPP enthusiasts who land here)...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号