The day I gave up on C++

C++[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.

73 Replies to “The day I gave up on C++”

  1. Hi guys, what about C++ Builder XE IDE? I like delphi and c++ builder very much! They are elegant!

    But sadly, they are windows only though they can develop cross platform apps.

  2. In the case you need to write a native program, you can intentially limit yourself within a subset of the C++ language, which is much easier to write and much less nonsense than in pure C.

    I learned this language a few years ago before C++11 was published, but this new standard made me feel like it’s faster to learn a different language than to add these new additions to my mind. However, you would not feel like so if you always only use a subset of the language, e.g. limited usage of template, exception, etc. This is also what the GCC project has done:

  3. i’m an expert in C# and wanted to learn vc++, so i was quite surprised by how much documentation sucks and the whole thing is complicated, the language is not that hard to learn but naming conventions suck, header files suck and everything you have said.

    i was searching online to see if others share my concerns, you should be given a medal since you summarized everything i feel now.

    MS corrected everything with .NET but they left VC++ fucked as shit, even errors that popups up in errors list suck, 99% of the error message is fucking symbols and shit qualified by header names and namespaces that you cannot understand a shit. i spent 5 mins to understand the overloads of a function from the intellisense as the tppltip is filled with fucking symbols and no direct understandable function parameters like C#.

    it really hurts me to see a wonderful languages that is actually the mother of all languages get fucked like this.

  4. You spoke earlier about that other languages are not amazing you. That’s what I feel myself. They look like pampering difficulties instead of solving them.

    Still… I admit that one language out there, aside C++, amazed me: is Rust.

    I don’t really like it’s syntax that much, but I like it enough.

    It is like C++ with unique_ptr and const by default, but also with null-dereferencing compile-time error and so on.

    A bit of static analysis would do almost the same over C++, especially in analysing the lifetimes. Still, the C++ would need a “unique” keyword, as Bartosz MILEWSKI was hinting at.

  5. I think STL will be greatly (I mean GREATLY, GREATLY, GREATLY) improved with the arrival of Concepts Lite.

  6. @Alex P: The lack of ABI is also a kind of politics. To make long story short, as long as there is no ABI, the language is inconturnable if one has to extend a codebase already in C++. This ensures C++ is needed. Throw in an ABI and suddently tyou could use Java or whatever in order to extend the same codebase. Principles are one things, realpolitik is another thing. Note that I don’t take sides, just expose the understanding of the situation.

  7. I spent the last hour trying to work out why:

    typedef std::map<int, int> TABLE;

    void f(const TABLE&) {…} ;

    const std::map<int, const TABLE> tables;

    const auto table = tabled.find(i);

    Doesn’t work. At this point, I just don’t care — the STL and C++’s slightly weird definition of const is getting in the way of me getting my job done. I’m going to try striping the consts out to see if that helps (heaven knows, instantiating my tables object in the overall class’ constructor required sacrificing some goats), and after that I may just use something different entirely.

    I’ve been programming as a hobby for about 25 years and professionally for 10. I’ve used piles of languages. C & C++ have some unique things going for them… but they are such a pain in the ass to get anything actually done in. I’m currently paid to work in C++; I think for my next job I’ll look for some other language if I can manage.

    Wonder if I could convince my ‘but it’s soooo faaaast’ coworkers that we should port to a faster language… like Fortran. Probably shouldn’t, they might just say yes.

  8. Worked it out! map.find(x) doesn’t return an iterator to the value in the map associated with x… it returns an iterator to the std:: pair(x, value). So that last line should have been:


    To which I can only reply, f– the C++ STL. Yes, you can do some interesting complex things this way. Was it really worth making using maps unintuitive worth it?

    That’s an hour or two of my life I’m not getting back.

  9. Another hour, another piece of horror worked around.

    typedef map<uint, map<uint, uint>> MAPMAP;
    const MAPMAP immutable;

    This doens’t work:

    MAPMAP& mutable = const_cast(immutable);

    This does:

    MAPMAP& mutable = const_cast<MAPMAP>(&immutable);

    Screw it, I’m plucking my eyes out, abandoning my career as a programming, and taking up a simple life as a blind goat herder.

  10. Edit: That should have been:

    MAPMAP& mutable = const_cast<MAPMAP*>(&immutable);

    Forgot the extra * in my const cast example.

  11. Well since you like C# so much, let me tell you something about C#, every time MS releases a new version of VS and C#, you will have to buy a whole book in order to know every new functionality that C# has, and sometimes its not the libraries that change, but the core language itself! I wonder, how are you .net guys productive with such a language, that changes at every release! And yet you consider C++ as having to much features…
    Not to mention, the funny relation with open source, and even if you could mention mono and stuff, but MS can kill them and all of they users if they want to, they only have to start using the patents they have over .net.
    And, just for that C# isn’t more portable than C++, unless you consider the world only as MS platforms, in that case you’ve got so much to learn.
    But, you are right on boost, that is probably the worst piece of software written for C++, that thing is a huge hack and exploit of C++ standard and compilers.
    Also you’re right on editor support, and the fact that no one does it right not even YouCompleteMe, since that even if using clang its clever, the wrapper around it is constantly crashing.
    You’re also right, when you talk about the #include kludge, and that it would be much more easy if C++ just used modules and require as a keyword.

  12. I wouldn’t overestimate the desire of Microsoft to get back to the blood-sucking image they created for themselves in the late 90s. C# is quite a healthy language and it doesn’t grow THAT much. There are very few features added over the years, even if the framework grows.

    Do not mistake the framework for the language. I don’t like the framework much, only parts of it (the System parts).

  13. To my mind, OOP is a bad attempt to create 3D objects in the flat world. We have got binary data, but need to define copy constructor. If one object not equal even in one byte, why it is a copy? It is stupid to my mind. More calls to memory allocation in ‘new’ will create a lot of fragmentation and garbage collection. What is the price for such memory management? The price is bad multicore support. It is too big price. Abstraction reduces functionality. Hiding methods will activate unexpected usage. So, every programmer must understand full functionality any way, to avoid unexpected usage. And if so, why I must use abstraction? It solves nothing, on the contrary creates additional problems. In C I can define struct. Inside struct I can define massive pointers to functions. First parameter for function can be pointer to struct type. Second parameter can be any I want. Why I must use a lot of inheritance, templates … for a simple things? Is it only for wasting time? To test program I will need to create 2 in degree of amount ‘if’ inside a program for test combinations. Why I will need to add extra ‘if’ from parsing xml? I have got enougt test combinations without parsing. For 32 ‘if’ I will need to check 4294967296 combinations of input data. Even if I will spend 5 sec for each test combination, I will not be able to finish work. Nobody live so long 🙂 How are they going to use jUnit, if they add additional ‘if’ for debug test system? Are they crazy? Will OOP reduce number of ‘if’ statment? No.

  14. I’m a professional programmer with HUGE EXPERIENCE and what i have to say is: “C++ IS NOT FOR EVERYONE 😉 !!!”
    I have been programming for at least 11 years in C, C++, Java, C#, PHP, Javascript, Shell and BASIC so may i’m right for what i say: “C++ IS NOT FOR EVERYONE !!! “

  15. FORTRAN, Algol, BASIC, assembler [various], C, C++, Javascript, PHP, Java etc

    I’ve programmed in all of the above since early the 1970’s and each has strengths and weakness etc.

    BUT only C/C++ is a real system / application development language. It’s an open standards language and is not owned by any big che$$e either. Although I do fall asleep if anyone starts on about some of the darker [obscure] areas of C++ and some of the new ‘fancy’ who-the-f##k-asked-for-that and what-the-hell-does-it-mean bits that people seem to want.. If you can’t manage with classes, file i/o, sockets and maybe a GUI and graphic lib then you are being a bit precious.

    Trust me I’ve spent many a project working with people who feel weak at the keys at the sight of a command line and would panic without a mouse. Bless them.

    I would not like to write an OS, or decent AAA game, or a fast and efficient cross platform data server or any mission critical application in any other language.

    Fair enough there are some who love Java for things like Android apps [which itself sits on top of an OS written in C/C++] etc and some will love the niche or propriety languages [ micro$not c$$ anyone ?].

    Anyway that’s enough from this old dog and good luck to all you new puppies, enjoy it all.

    I’m off for a walk to visit another tree.


  16. I wonder about what you said about the IDEs for C++.
    Since you said you don’t like these IDEs, I wonder what IDEs you do like and why?
    What would your perfect dream IDE be like? What features would you like it to have to make you pelased and satisfied?
    And what exactly are the things you don’t like about current IDEs?
    (Hey, maybe it’s a good idea for an article? The pros & cons of IDEs.)

Comments are closed.