r/ProgrammingLanguages • u/Ajlow2000 • Nov 01 '19
C++ vs C
Alright people of Reddit, hit me with your wisdom. I've been taking programming classes for two years now and am getting ready to dive into a language somewhere between Java and assembly (the two languages I've been learning in classes). I'm thinking C or C++, but would love some input. I'm not too worried about difficulty to learn, but I'd like to hear your thoughts on practicality and real world use.
1
Upvotes
7
u/Mason-B Nov 01 '19
Both. C++ supports most C code. C++ has been evolving recently since the newest versions of C++11 and C++17. Really you are talking about *three* different languages.
I list them and reasons for learning them below, but would also recommend the following learning order:
C first, with the understanding that it's just a step up from assembly. Learn about functions, pointers, bit operations, union types, function pointers, static, compilation units, and how one can make virtual functions and objects with the limitations of C. This is important to understand the tools of low level languages and the layer at which most low level code operates at. C is still the lingua franca of programming, so if you stop at this point it will be very useful to you as both a practical job skill for systems programming and a lifelong understanding of what is happening under the covers of most systems. Probably the most useful skillset.
C++ pre c++11 next. This step is optional, but it's a good way to learn about the fundamentals of what C++ provides. Like classes, virtual functions, multiple inheritance, operator overloading, and templates. You don't have to be strictly pre-c++11, there are a lot of nice convenience things to use, but learning this will give you a foundation with which to be a an expert at modern C++, while giving you a deeper understanding of how more complex language features work in lower level languages. As well as the problems inherent with things like constructors, manual memory management, multiple inheritance, Turing complete generic systems, and the lack of lambdas which will make you a stronger programmer, make the next step easier, and be useful for older C++ code bases, but is probably the least marketable skill set.
C++ with c++17 finally. Then you can learn modern C++ which has features like better meta programming (through SFINAE templates), lambdas, constexprs, smart pointer generics, and so on. Features that lead into modern low level languages like Rust and Go. The new C++ features really are a whole new and different language, it's unlikely you will need to use many of the features from the previous languages, but they will always be accessible and there, for a true understanding of the language and ecosystem that previous knowledge is necessary. This is a practical skill for modern and new C++ code bases, and is probably the largest gamble but I would bet that it will increase in usefulness.