[This is an article written in 2013. Things have changed, not a lot, but they have. Every time someone discovers this post via reddit I feel like taking it down – it’s not particularly good, it was written when I was quite upset with my lack of ability to become productive in C++. I will not bother you with the updated view, and I will keep the article because people seem to stumble into it every now and then, probably because they are equally frustrated and, like me, they didn’t know how to express it. I am tempted to do a rewrite of this, though (and I have)]. I wanted to mark this somehow, in my calendar or something. I always liked C++ as language, it was nice to build so many nice things with it. I learned C++ when I was in 11th grade, and I kept learning for years. Probably everything that I know about design and design patterns I pass through the C++ filter. I map all the things I learn in all other languages through C++, and understand them better. I must confess, I always loved C++ like that.
But, C++, this relationship doesn’t work anymore. It’s no longer love, and before we split I want to tell everyone why: You’re ugly. You wanted to be a splendid girl, and borrowed the flexibility of your older sister, C. You just wanted to do too many things. You grew up among bearded fellows that made you do all the wrong things, like your sister used to do. But it didn’t work out that well for you. And I was younger, didn’t know better, and I fell in love. But the thrill is gone, now.
A famously quoted joke is the following: what is the 11 in the C++11? It’s the number of feet they glued to C++ trying to obtain a better octopus. Of course, it didn’t work.
And I must confess, C++11 looks tempting. If you write your code from scratch, C++11 might be an option. But when I say from scratch, I really say from scratch. Write your own libraries for everything. And for Christ’s sake, replace completely the STL! Boost? Don’t make me laugh. Boost is a Vernian, submarine sized octopus that is out there to kill you.
Let’s take my reasons one at a time:
C++ IDEs suck. Big time. I tried about 10 IDEs in the last two months. They all suck big time. Not only do they suck, but they are counterproductive: Visual Studio the absolute best IDE when it comes to C#, wants to make a point from actually sucking in an equal quantity for C++. Eclipse made me cry, netbeans sucks, kdevelop sucks, code::blocks sucks, codelite sucks, monodevelop sucks and whatever you might suggest that is the next best thing in IDE sucks too. Trust me. Now, I know, this is not the language’s fault. But you’d expect that after all these years of experience, of needs for C++ support in IDEs, you’d see some improvement. No, the IDEs become proud in sucking more each year in their C++ support (of course, Eclipse does that for all the languages, but that’s a different story).
It’s an unmanageable language. You have header files split from source code. Why? Because in the 70s and 80s it was difficult to have proper metadata in object files. For C, it makes sense: it makes writing a compiler a lot simpler, if you don’t count the number of people that killed themselves after writing the preprocessor of C. But we understand C. C is cool. C is simple. C is meant for other stuff. But in C++, header files are the rope that you hang yourself with. You don’t want to include the same header file two times, so you use, what? Header guards? #pragma once? All these are error prone (#pragma once for not being supported by all the compilers). So what do you do?
It’s a barely portable language. If you want to write things portable you have to #ifdef stuff. This, of course, makes your source code ugly. Right now, C++ is less portable than Java or C#, that really have this ‘write once, run everywhere’ thing.
It’s a counterproductive language. The real reason for me being so upset with the language is the fact that the language constantly gets in the way of my project. I started working on my own game ladder, and wanted to start with PONG. Easy, right? Wrong. It’s almost impossible to understand how you keep in standard containers objects created by some libraries. And when the standard library is the obstacle, it’s definitely an issue.
Talking about STL, STL sucks. I know, it’s the fastest and sharpest knife in the kitchen. But it sucks. It sucks because it is so intrusive in your code, because you never know if you should create containers on the heap or not, it sucks for the uninspired names and for the unstructured approach to the containers. You don’t have an ‘Add’ function, instead STL has a push_back, but not for all containers. No, for stacks you’ll have a ‘push’. ‘Remove’ is called ‘erase’, and the ‘remove’ you see there is not what you expect: you have to use erase with the result of remove. You don’t have a unified interface for containers, and you can’t simply say: I want something that I can enumerate, which is what you want most of the times.
The focus on performance actually makes STL impracticable. STL is optimized for the compiler, and it’s counterintuitive. And some smart-asses will say: use boost instead. Boost is smart. No, sorry. BOOST SUCKS. Boost is the ugliest piece of software ever created. It’s useful, but ugly. And no person alive could ever cover all of Boost libraries. Why would they? Ah, they have to, because IDEs will never ever ever help you with that.
And let me mention the namespace stupidity. Because STL is so bad, boost and others create their own containers. The best toolkit to use with C++ is by far Qt because they rewrote everything from scratch. But the problem is that you will have constantly nameclashes. So, I C++, it’s bad manners to use the ‘using namespace X’, especially in the headers. Which makes quite common definitions like:
Call me when you get what I have there. Compare this with List<Drawable>, and let me know which is better.
The language sucks. It sucks because it’s so complicated. C++11 managed to complicate it even more, and now you often wonder how many ampersands you have to place in your constructor? STL is unusable, is counterproductive and makes your programs unreadable.
Any beginner will be crushed by the statements C++ programmer have to write. So from now on, I will recommend to any beginner to jump from C to C# or Java. It makes much more sense, really, do it.
And I say this with great regret in my heart. I always loved you, C++, as ugly as you were. But now the thrill is gone: you became unusable and counterproductive, and I really have no time to write proper containers in 2013.