Alternative point of view on C++11
Everybody loves C++11. What’s there not to like? In fact everybody I know wants to switch to C++11 at the first opportunity, including me. This is because C++11 is a better language than C++98. Or is it?
John Sonmez argues in his post that besides all the great new features which make C++11 feel like a new language, there is one big problem with it – it’s HUGE!
I agree with John’s statement, C++ has grown big. It’s been hard to learn and master. It’s even more complex now. I’ve been learning C++ for many, many years, and it still surprises me sometimes, and I haven’t started using C++11 in everyday code yet.
There are lots of very nice features in C++, but there are also lots of features which are tricky. There are features which invite bugs. Sure, friends, multiple inheritance and even goto all have their place, but in most cases they will make someone miserable in the long run. And it’s not about “don’t like them, so don’t use them”. It’s about all those unexperienced programmers who stumble upon them and think they are a good idea to use.
One possibility to improve this state could be to remove, limit or forbid certain features. Subsetting is discussed every now and then. As good a solution as it may sound, it won’t solve all the problems. Some suggest the problem lies in C++’s compatibility with C. So subsetting definitely won’t solve this, as the remaining features will need to remain unchanged.
I suspect Andrei Alexandrescu would say something like: “Don’t like C++’s complexity and C compatibility? Switch to D”. Yes, there’s that.
C++ just can’t break backwards compatibility. This is why new languages are created. One day some programmer or group will gather all the best ideas from C++ and create a new language, which will be simpler and will avoid many pitfalls of C++.
Until that happens, I will happily look forward to using C++11 in my projects.