Yay, it’s been so long since an uninformed C++ rant.

March 3rd 2009 01:03 am

You may start by reading The Tailor, off of Planet GNOME.

Back? Good. Let’s deconstruct the points :) (Quotes are abridged and not direct quotes because I don’t feel like doing the copy-editing required)

  • Methods should be virtual by default so inheritance works. Well, inheritance at run-time, since inheritance still works just fine. To be honest this is probably one other thing that could have been different between class and struct, is class having all methods be virtual while you need to specify it with struct, so that you can still write simple classes with little to no overhead, such as QColor for instance. Then again, you could actually spend the 5 minutes it takes to understand non-virtual functions (hey wait, we already know how non-virtual functions work! :) and move on with your life. Also, this is snark’s most frustrating issue with C++… I don’t know if he’s referring to the same language I am but there’s about a half-million things more annoying than virtual in C++.
  • You need to have virtual base destructors in classes with virtual methods otherwise Bad Things Happen with no warning. Except that there is a warning. Fair argument though, I remember even Qt wasn’t immune when the warning was first introduced (or turned on with -Wall) by g++.
  • It’s annoying to use multiple inheritance because you have to be really careful. Then don’t use multiple inheritance, just like GTK+ and Java don’t use it.
  • Conversion constructors are annoying because they enable a type of bug, which the C++ guys thoughfully included a keyword for to avoid automatic conversion. If this kind of bug really trips you up, don’t use conversion constructors at all. Hey, less code to write!
  • C++ lets me do other unsafe things. True. So does C, Python, Perl, Ruby, and etc. etc. etc. Are we really supposed to pine for languages that put you in a straightjacket? If you don’t like features which are potentially unsafe, then don’t use features which are potentially unsafe.
  • Don’t respond that the language isn’t at fault because that proves you’re drinking the Kool-Aid No language is without fault, but it hardly seems sporting to say that C++ is bad because it gives you more options. If you want a more restrictive language then use Java or C#.

Or to put it another way, I don’t like spicy foods. At all. But you don’t see me blogging about how spicy food is horrible, OOHHHHH NOOOO HOW DO YOU EATZ SPICY FOOD????, etc. The reason I don’t is because I know that many people enjoy spicy food, and because I DON’T HAVE TO EAT IT IF I DON’T WANT TO.

On the same note here, most of these points against C++ are things that other programmers actually desire. I like implicit conversions in some cases (although I’d rather have an implicit keyword than explicit). I certainly like having the option to have simple classes that don’t necessarily have to have a vtable, even if that means I need to remember to make my methods and destructors virtual.

Worse yet, this is a rant with no solution. C++ can’t change now, and there are plenty of popular languages out there where this list of complaints don’t apply. So why the rant on C++ when you could be writing your Vala application? Or to bring back the tailor analogy, if you could tell that the suit didn’t fit when you put it on, why did you buy it anyways, when there were other perfectly good suits available, and other men fit into your poor-fitting suit just fine?

I suspect that snark has never actually used C++ for anything substantial. Or if he did, I’m very shocked that “templates” didn’t make his list at all…

Posted by mpyne under C++ & Personal | 26 Comments »

26 Responses to “Yay, it’s been so long since an uninformed C++ rant.”

  1. Janne Identicon Icon Janne responded on 03 Mar 2009 at 02:56 #

    What’s especially classy in his comment is this:

    “Read any document about C++ : this language has all bells and whistles, with options everywhere (do I dare saying “A real KDE!”? No, that would be trollish).”

    That’s like walking up to someone and saying “I could call you an ugly moron…. but I’m not going to”, and then act surprised when the other person gets pissed off (“hey, what did I do? I didn’t call you an ugly moron!”).

  2. ruurd Identicon Icon ruurd responded on 03 Mar 2009 at 03:49 #

    Oh come on guys, we really do not need to take this serious. It’s an uninformed rant by a belligerent troll… Let it go. Your heart will love you. :-)

  3. Esben Mose Hansen Identicon Icon Esben Mose Hansen responded on 03 Mar 2009 at 03:53 #

    Well, at least he didn’t find out the triple-overload of the word “static”, or the fact that C++ STL algorithms are a pain to use because they really need a proper lambda, or the way switch cases defaults to fall-through, or one of the other hundred things C++ does in weird ways :)

    These days, I just tell people that C++ is the worst language I have ever used, except all the other languages I’ve tried.

    At least C++0x looks to fix some of the most annoying stuff. I love the fact that we will FINALLY get a proper lambda. Oh and concepts looks very interesting. When I get that in gcc, I will be drunk for a week with celebration :D

    PS: I find the, eh, insult against KDE really cute. Because that I *want* a system with all the bells and whistles and options :) Some people do prefer a straight-jacket, and I point them to Gnome — which makes them happy, Gnome happy *and* me happy. Triple win!

  4. Andreas Identicon Icon Andreas responded on 03 Mar 2009 at 04:20 #

    Re Esben and static:
    My pet peeve (because it’s so gratuitous) is the reluctance of the standards committee to introduce new keywords. Search and replace are really simple enough and more is not required to keep old code working when new keywords are added.

    Most other problems are along the lines of “it is required for performance reasons” and “it seemed like a good idea at the time, to many smart people”.
    D fixes most (all?) of the non-gratuitous problems with C++ but there are no libraries :(

  5. Andreas Identicon Icon Andreas responded on 03 Mar 2009 at 04:23 #

    s/non-//

  6. Anon Identicon Icon Anon responded on 03 Mar 2009 at 04:30 #

    “PS: I find the, eh, insult against KDE really cute.”

    I often wonder if anyone has ever scoured the two planet$DE’s and done an informal count of how often they make some kind of backhanded comment or outright attack on $OTHERDE. From my brief couple of weeks subscribed to planetgnome (maybe I picked a bad time, but most blogs there seemed to be purely “personal-life” blogs, bickering amongst the developers, and hardly anything about, you know, actual development of GNOME), I suspect that GNOME would come out way, way ahead. I understand this kind of behaviour coming from end users (like me :p) but seeing it come from the developers themselves is really … odd. It’s like a contingent of them are still stuck in the “GNOME vs KDE – it’s War!” mindset, and nobody has told them that the Free Software landscape has moved on since then.

  7. defective Identicon Icon defective responded on 03 Mar 2009 at 04:35 #

    More reasons against C++:
    http://yosefk.com/c++fqa/

  8. ricard Identicon Icon ricard responded on 03 Mar 2009 at 05:26 #

    food is bad, because I don’t like spicy food and food can be spicy.

  9. S.F. Identicon Icon S.F. responded on 03 Mar 2009 at 06:54 #

    Actually, he uses it currently within Ekiga, which, despite using Gtk+, is written in C++ from the bottom up.

  10. Esben Mose Hansen Identicon Icon Esben Mose Hansen responded on 03 Mar 2009 at 06:55 #

    defective: Whoever wrote that FAQ is not the sharpest knife in the drawer. Take this quote, more or less randomly picked:

    Templates are mostly applicable to containers or smart pointers, which can contain or point to almost anything.

    Well — no, not even close. Currently I am using the boost::units library. That is not a container library, nor would it be possible without either direct language support or some time of generic programming. Just a random example :)

    The problem with the error messages *is* a real problem and is going to be fixed The symbolic debugger thing is mostly a problem with the debugger, which is supposed to be fixed soon. But then, I suspect the FAQ writer mostly wanted to rant :)

  11. Shawn Identicon Icon Shawn responded on 03 Mar 2009 at 10:44 #

    There is a certain immaturity of GNOME that has irked me. GNOME would have been written in C++ had maturity existed when they started the project instead of the FUD and nonsense spewed about C++.

    *sigh*

  12. hb Identicon Icon hb responded on 03 Mar 2009 at 11:20 #

    I don’t really see where you “deconstruct” any of these points. Except, of course, by “deconstruction” you mean to say “yes, I know it’s bad, but you don’t have to use it”. All together, I don’t know where the “uninformed” in your headline comes from. You certainly don’t crush anything here. The “other languages are bad, too” argument is not really convincing either.

    Although I personally enjoy C++ much more than, say, C, I find myself in agreement with many C++ rants. That the same statement applies to, say, C or Python, doesn’t make the articles less valid.

  13. A Non Y Mous Identicon Icon A Non Y Mous responded on 03 Mar 2009 at 11:44 #

    hb: if someone blogs that the most annoying thing in c are whitespaces, then you can conclude that the bloger has no clue and spreads an uninformed rant. deconstruction successful completed.

  14. hb Identicon Icon hb responded on 03 Mar 2009 at 11:52 #

    A Non Y Mous: As I said before, this blog post doesn’t crush any false claims of the referenced post.

    And I don’t see how e.g. ranting on a personal blog that whitespace is relevant in Python is bad, or FUD, or uninformed. A analogous “deconstruction” would be: Use Perl. You may call this “successful”, I don’t.

  15. blueget Identicon Icon blueget responded on 03 Mar 2009 at 15:51 #

    Why don’t all the people just use the language THEY like instead of putting so much energy in ranting? I’ll never understand that.

  16. hb Identicon Icon hb responded on 03 Mar 2009 at 16:45 #

    blueget: Because in the real world, you are rarely free to choose your programming language. Even in the FOSS world. Except, of course, when you are starting a new project (which is a very rare case), or you chose your contributions according to programming language preference instead of interest or to scratch personal itches (not very smart, in my oppinion).

    For (smart) application developers, programming languages are tools, not ends in themselves.

  17. fcg Identicon Icon fcg responded on 03 Mar 2009 at 17:30 #

    OOHHHHH NOOOO HOW DO YOU EATZ SPICY FOOD????

  18. Eckhart Identicon Icon Eckhart responded on 03 Mar 2009 at 18:42 #

    Actually, what I actually think is worse is that “put your comment in /dev/null and read the last paragraph again, tailor!” sentence. The tailor metaphor tells something about someone thinking all problems can always be located at the opposite side. He thinks of it as a clever way to deconstruct every criticism as C++ fanboyism and therefore invalid. However in my opinion this actually puts *him* into the role of the tailor (because now he can’t be wrong anymore).

    Oh, and I would have commented on the original post if there was an obvious way to do that.

  19. mpyne Identicon Icon mpyne responded on 03 Mar 2009 at 19:43 #

    ruurd: :)

    Anon: I also find it disappointing that some people are still trying to maintain hostilities, as it is counter-productive for everyone.

    S.F.: Well, I stand by my surprise. :) Esben and Andreas have both posted IMHO valid complaints about C++ that hold much more weight.

    hb: My argument is not that other languages are bad, or “as bad”. My argument is that if other languages are better, then use those. Or if you can, at least complain about actual problems instead of things that irk you personally. Plus, even if you don’t get to pick your favorite app’s language in FOSS, you can certainly port it to a language that doesn’t suck if you’re that motivated.

    Eckhart: That was a good half the reason for me making my own post instead of posting a reply on his blog. I understand why he’s doing it though. (I needed to have like 3 separate anti-spam plugins on mine before I could disable requiring logins).

  20. hb Identicon Icon hb responded on 04 Mar 2009 at 03:23 #

    mpyne: “I also find it disappointing that some people are still trying to maintain hostilities, as it is counter-productive for everyone.”

    So “uninformed”, “belligerent troll” are not hospitatilites, even personal insults, as an answer to a technical rant.. okay, whatever you say. And no, your post didn’t show his “uninformedness”, so your headline is actually a personal attack without backup by facts.

    “at least complain about actual problems instead of things that irk you personally”

    So now, you’re surprised (or annoyed?) that someone write about things that irk him personally on his personal blog? This is getting absurd.

    “you can certainly port it to a language”

    More absurdities. Sure, you can do that, or you can get work done. In any case, you can write about your experiences on your personal blog. Choice is beautiful, isn’t it?

    Many comments here show a weird spirit. There’s indeed some ranting going on on Planet Gnome from time to time, and most of the time it’s actually about Gnome’s own or closely related technologies. Guys, if you can’t stand a critical mind, just don’t read Planet Gnome.

  21. mat69 Identicon Icon mat69 responded on 04 Mar 2009 at 05:14 #

    Well imo tailor simply does not get c++.

    It simply bails down to “If you can’t stand the heat don’t enter the kitchen.”

    Yes, c++ is/can be very uncomfortable — though imo I never had troubles with the virtual keyword once I learned about it — and that has to do with its design goals and the way it evolved.

    Here the coder has probably more ways to get something wrong while other languages make life easier. Though you have to pay a price, on the one hand “less” (nowadays not that important on PCs imo) performance, less controll, less close to the hardware or simply the reverse of that but having to take more stuff into mind.

    PS.: It is interesting though that some of the uncomfortable parts c and c++ share are not mentioned on that blog …

  22. Snark Identicon Icon Snark responded on 04 Mar 2009 at 11:43 #

    First : the comment about KDE… did you read it in full? That was more a wink on what is pretty often said about KDE than a serious attack. Just like you could have gone for the full cliché and compared gnome to a thong! Another thing you forgot to read is that I know implicit type conversion are considered a “don’t use”.

    For the rest, I read this post post less as a deconstruction of mine than a confirmation. “Not happy with multiple inheritance? Don’t use it! Not happy with the default choice for virtual functions? You’re too stupid to add a simple keyword!”. For any criticism I made, I’m told that it’s my problem and I just don’t get it.

    But I do use C++. And if I start something, I generally manage to get something correct… if I don’t start, then things can go wrong : go find a lib with say fifty classes, each with something like fifty methods, some virtual, some not, and try to extend it in a way which wasn’t foreseen by the developpers. The compiler will gladly tell you about the public/protected/private problems : good. But for the missing “virtual” or the dreaded diamond? The compiler will swallow the code and say thank you. You’ll have to discover the problem yourself, understand which method is the culprit, track through the inheritance hierarchy what exactly happened.

    I could have ranted about many other things too, indeed, and some will be fixed with C++0x (drool).

    PS: comments are supposedly enabled on my blog, and my closing remark was more to force people to think twice before flaming than to refuse them.

  23. mpyne Identicon Icon mpyne responded on 04 Mar 2009 at 17:16 #

    First off:
    hb: Learn to read, I wasn’t talking about Snark at all when I was talking about people maintaining hostilities, I was referring to those who took the opportunity to bash GNOME on my comments just because I linked to Planet GNOME. You may not have noticed that was essentially the exact point Anon (whom I replied to) was making.

    Snark: I read the comment about KDE and saw your wink and that’s why I didn’t reference it at all in my response. Because it attracts fanboys on both sides I try to avoid snarky comments at all toward GNOME in general. Even obvious jokes will be misinterpreted by people.

    However, I think you read too much into what I wrote when you say it validates your argument. The first thing I said about virtual functions (after the inheritance correction, that is) was that it was probably something C++ could have improved on by making them default for classes but not for structs (i.e. agreeing that virtual functions could have been improved when C++ was being designed). I even noted for example that the warning about missing virtual dtors was only a recent g++ addition.

    But what I’m trying to point out is that there’s a world of difference between complaining about a feature being wrong or misdesigned and complaining about a feature being present at all.

    For instance not forcing virtuals on is useful for many programmers, even if it sometimes makes your life difficult. So complaining about class not making virtual by default instead of complaining about C++ having non-virtual functions is more appropriate IMO.

    At the same time you seemed to be complaining about the mere existence of multiple inheritance instead of the compiler not helping you out about diamond inheritance, which are different. C++ is the only major language I know of where MI is even an option so whether the compiler could warn better or not it has to be that if you break it, you buy it if you’re going to use that feature.

  24. Snark Identicon Icon Snark responded on 05 Mar 2009 at 00:44 #

    Well, in my opinion having virtuals off by default is both a premature and aggressive optimisation. Non virtual shouldn’t be forced by default, as it makes inheritance a less natural and automatic thing, even if it can be good for performance reason. I really have the impression they made the corner case default, and thus made the general case a little too painful.

    Concerning multiple inheritance, the language which is my reference about OO programming is eiffel — and it does it very well, both from the point of view of features and the point of view of usability : you can decide what you do on a method-per-method basis if you need or on the whole class level, and you deal with it at the point where you have the problem, not three levels up. Ocaml isn’t bad either at it.

    They’re unfortunately not in the “major language” league (yet — F# is ocaml in disguise), but perl and python are, and have multiple inheritance (with the same method resolution if I remember well) — with issues and silent breaks too though.

    And please don’t tell me “don’t use”… I am careful if I start something — the problem is extensibility when I come accross another piece of code! The fact that inheritance problems have to be dealt with in the base classes and not in the child class where the problem appears is pure pain.

    PS: eiffel has something called “constrained genericity” which looks like what “concepts” will bring in C++0x… so once again there’s nothing new under the sun, even if I’m drooling forward for C++0x.

  25. hb Identicon Icon hb responded on 05 Mar 2009 at 08:45 #

    mpyne: Rest assured that I am capable of reading — even though I obviously misunderstood your (in an ambiguous way formulated) statement.

  26. mpyne Identicon Icon mpyne responded on 05 Mar 2009 at 14:43 #

    hb: I apologize, my tone was much harsher than I intended. I am sure you are capable of reading, and I have misunderstood many things myself due to ambiguous wording. So I see why that would have happened here.

    Snark: Well I definitely agree that C++ makes it harder than it needs to be to design a good object-oriented API, even if I disagree with some of your specific objections, it is a fact that C++ introduces issues overall into the API design for a library or project.

Trackback URI | Comments RSS

Leave a Reply