Last year, the new C++ standard C++11 was finally published. It contains lot’s of interesting new stuff like lambdas, a threading library, a memory model, hash tables and much more.
See Bjarne Stroustrup’s C++11 FAQ for more on the new standard.
Nicolai Josuttis, author of the wonderful The C++ Standard Library: A Tutorial and Reference (2nd Edition)
recently said in an interview:
“Due to the complexity of C++, the support for the ordinary programmer is incredibly bad compared to other languages, and that’s a major drawback.”
I agree (but make sure to read the whole interview). Despite many improvements in C++11, C++ is still not an easy language. Java, while not as easy as some may think, is still an easier language with very good performance (often almost as fast as C++) and offers better IDEs (maybe Visual C++ is as good as current Java IDEs but no luck here on Linux), a much more comprehensive standard library (the JDK), more libraries (e.g. Hibernate, Spring, JEE, Lucene, etc) and no memory leaks (well, almost none – you can still build a memory leak in Java but it is more difficult to do so than in C++). To be fair, with modern C++11, it is much easier to avoid memory leeks.
Still, there are at least 4 very good reasons to learn C++ in 2012:
1) Raw performance
In some cases, highly optimized C++ can be faster than the best Java code. This won’t be easy and really tuning C++ can be time consuming (similar to all other languages) and error prone. Still, sometimes this is just what you need. This might be interesting, for example, with large data centers, scientific computing, bid data analysis, etc.
2) You are closer to the OS and Hardware
Although you can wrap OS system calls in other languages like Java or Python, sometimes you want to be very close to the OS, e.g. when writing device drivers or low level network servers. In those cases, C++ could be your fried. I would prefer C++ over C here as C++ is much more powerful and has a much better standard library.
3) You learn something!
This is the most important reason for me. I learned C++ more than 10 years ago and I learned a lot about programming, design and how to write clean code. And I think EVERY programmer should have used a language that requires you to allocate and free memory (it is much easier now with the latest C++ standard and stuff like smart pointers but you still need to understand how new and delete work in order to properly use C++). Many Java or Python programmers forget all about memory. Learning C++ will help you learn about memory management.
The C++ standard template library (STL) is one of the best crafted libraries out there and you will definitely learn something when you improve your understand of using this powerful library.
4) C++11 is much cooler than the older C++
C++11 has many cool features like lambdas, auto keyword, move semantics and much more. It is definitely a much better language than C++98 was.
See this overview by Herb Sutter about the new features in C++11:
Elements of Modern C++ Style.
To sum up, I think everyone should learn at least some C++. If you have been programming in Java, Scala, Ruby or Python for the last decade and never touched C or C++, now with C++11 I think it is time to learn C++11 and improve your programming skills while doing so.
I probably won’t be using C++ much at work in the coming years and when I need a more powerful language than Java, I will probably go for Scala, but I will have a closer look at C++11 and try to learn and understand the new features, particularly those about multithreading and concurrency.
Remember: It always helps to learn a new programming language even when you don’t plan to use it in production.
For learning C++11, here are a 3 good books (more on C++11 for sure will follow soon):
Great book on the new concurrency features of C++11.
The best book on the C++ standard library and one of the best programming books ever written. Now in it’s 2nd edition to cover C++11. I just god my copy and it is a fantastic book.