2 ms·
Instead of C++, I would advise learning C. If you are still interested in learning C++, I would still advise learning C first as C++ is (or at least was origina
by newt0311 18y ago
Instead of C++, I would advise learning C. If you are still interested in learning C++, I would still advise learning C first as C++ is (or at least was originally based on) C. K&R is probably the best way to start on C.
- apu 18y agoWhile I heartily agree that K&R is the best way to learn C, I'd strongly recommend against learning C en route to C++. Most "best practices" in C are usually frowned upon (or worse) in C++. For example, using c-style arrays (instead of Vectors), using pointers excessively (instead of references), malloc/free (instead of new/delete), lots of global functions/variables (instead of classes, etc). As far as picking between the two, it depends on your goals. If you really just want to learn about low-level programming, then C is probably the best option. On the other hand, if you want to be able to write low-level code for speed (i.e., to then call it from a high-level language), you might be better off with C++ (which is much more flexible while maintaining most of C's speed). Keep in mind, however, that using C++ effectively can get significantly more complicated than C (templates, classes, etc.), and so it is not usually a good idea to learn it "for learning's sake."
- pmjordan 18y agoI know probably 99% of the C++ standard and used C++ in anger for years, and I do not recommend learning it unless you need to do so. Getting into the (console & PC) game industry is one of the only reasons I can think of. Even so, most veteran game programmers use only a small subset of C++, and most of the code is effectively C. C++ is a terrible hack, and if you're very familiar with other languages you'll be shocked by what is considered beautiful or elegant in the C++ world. (e.g. Boost) If you want to just low-level optimise parts of a program written in a high-level language, C++ is actually a pretty poor choice. C is actually going to give you fewer headaches with language interop, as it has a standardised ABI. There are tools to do, say, C++ to Java interop, but I can't recommend even trying to do that kind of thing. In comparison, JNI (implementing Java class functions in C) is a walk in the park. Yes, you can do anything you can do with C in C++. Yes, C practices (char* strings, etc.) are considered bad style by the C++ world. I'm going to just come out and say it: in my opinion, the C++ world has no idea what good style is. As for learning C, it's a very good idea. You'll learn a whole load of things that will help you even when you're not using C itself. Hopefully, you won't need to use C itself all that much in practice, but it's a damn handy language to know, even if all you use it for is to write glue code between some libraries and your favourite language.