在 Linux 或 Windows 上学习 C++?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1621621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Learning C++ on Linux or Windows?
提问by Zed
Since you 'should' learn C/C++ and as part of 'learn as much languages as possible', i decided to learn C++ in depth.
由于您“应该”学习 C/C++,并且作为“尽可能多地学习语言”的一部分,我决定深入学习 C++。
My OS is Windows and my question is should i re-install Linux as a dual boot to learn C++ on Linux?
我的操作系统是 Windows,我的问题是我应该重新安装 Linux 作为双引导来在 Linux 上学习 C++ 吗?
Do i miss something if I develop in C++ only on the Windows platform?
如果我只在 Windows 平台上用 C++ 开发,我会错过什么吗?
(possible duplicate: https://stackoverflow.com/questions/1128050/best-operating-system-for-c-development-and-learning)
(可能重复:https: //stackoverflow.com/questions/1128050/best-operating-system-for-c-development-and-learning)
回答by Glen
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.
如果您想验证您的代码是否可移植,您可以安装 cygwin 和 gcc 以及 Visual Studio。
Then you could compile with both compilers without having to dualboot
然后你可以用两个编译器编译而不必双启动
回答by Charles Salvia
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.
如果您的目标只是学习 C++,那么您使用什么平台并不重要,因为 C++ 作为一种通用编程语言,不是特定于平台的。您可以使用合适的 C++ 编译器在任何平台上学习标准 C++。
回答by Zed
If you want to practice / test on Linux, you can simply create a virtual machine, for example with VirtualBox.
如果您想在 Linux 上练习/测试,您可以简单地创建一个虚拟机,例如使用VirtualBox。
回答by LiraNuna
回答by Federico klez Culloca
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.
如果你问的是 IDE、编译器等,那是你对它的偏好。
回答by mh.
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.
在我看来,你应该在最熟悉的平台上学习编程。如果您还不熟悉 Linux 及其功能,那么开始用它学习编程是没有用的,因为您不知道该做什么。您还可以期望 MS 文档比 Linux 文档更加一致。
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.
- 您应该获得一个随时可用的开发环境,例如 Eclipe 或 MS Visual C++ (Windows)。使用文本编辑器、makefile 等的“标准方式”对初学者来说太难了,尤其是在 Windows 上。
- 如果您打算在 Windows 上使用 .NET,您必须意识到该语言与标准 C++ 略有不同。对于 C++ Builder 等也是如此。如果您使用的是 Visual C++ 或基于 GNU 编译器的环境,则可以编写标准 C++。
- 您应该尝试使用 C++ 标准 API 和库,例如 STL,而不是 MS 专有的库,除非您想坚持使用 Windows。
回答by StackedCrooked
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++.
我建议您坚持使用 Windows 一段时间,直到您熟悉该语言。然后,如果您愿意,可以切换到 Linux。我这样说是因为在 Windows 上您可以使用 Visual Studio(可以免费下载 Express Edition)。它的用户友好性将减轻学习 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.
最后,您还应该使用 gcc、makefiles 和高级编辑器(如 vi/emacs/whatever)来学习 Linux/Unix 方式。然而,这本身已经是具有挑战性的东西,所以留待以后学习,先学习 C++。
回答by Michael Aaron Safyan
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 environmenton Linuxthan 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.
只要您坚持使用跨平台库(例如 C++ 标准库、Boost C++ 库和Qt 框架),而不是使用特定于平台的调用(例如 WIN32 API),并且还假设您使用跨平台平台构建系统(例如CMake),而不是特定于平台的系统(例如 Visual Studio),那么它就不重要了。也就是说,在Linux上设置 C/C++ 开发环境比在Windows上设置等效的开发环境要容易得多。而且,由于 Linux 将不包含“windows.h”头文件,因此如果您在 Linux 上进行开发,您将不太可能调用特定于 Windows 的功能。
回答by ndim
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.
如果在学习 C 和 C++ 的过程中,您想了解库和系统实际是如何工作的,Linux 是显而易见的选择,因为您可以查看系统的整个源代码。
IMHO, that can be quite instructive.
恕我直言,这很有启发性。
回答by Panic
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...
由于单独使用 C++ 你不会做太多,你应该同时使用两个操作系统(以及更多)来了解你可以使用的库、编译器和 IDE(甚至开发理念因操作系统而异),这并不是真的在您进入 C++ 的第一步中很重要,在那个阶段,您选择哪个编译器/IDE 更为重要...
Zed above rightly points you out the virtual machine option, VirtualBox is great.
上面的 Zed 正确地指出了虚拟机选项,VirtualBox 很棒。
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...
我个人建议避免使用 Visual Studio 作为您的第一个 IDE/编译器,它会增加复杂性并试图一有机会就将您洗脑到 .net。这也将使您以后难以转移到其他设置...
Start with a simple text editor (Notepad++ on windows) and by using the command line for compilations.
从一个简单的文本编辑器(Windows 上的 Notepad++)开始,然后使用命令行进行编译。