....go and play in your little world...It looks innoculous enough here and now, but in the context it was realy ugly. And now, for some time everyone seems to feel obliged to speak about Linus' C++-hating post*, so I had a look at it myself. OK, nothing changed, it goes in the same vein:
*YOU* are full of bullshit. ...... is likely a programmer that I really *would* prefer to piss off, so that he doesn't come and screw up any project I'm involved with. ...... the end result is a horrible and unmaintainable mess. But I'm sure you'd like it more than git.... etc, etc, etc. OK, maybe it's only his personal creative writing coach who's to be blamed, or perhaps it's the macho Linux kernel developer culture? But, aside of personal dislike, what the man says got a bell ringing with me. Why? Read on:
C++ leads to really really bad design choices. You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes:Whoa, that man is really hardcore! What he's actually saying is: don't trust any code you didn't write by yourself! And on a higher level: any abstraction we are using is a trap, lulling us in a false sense of security. And more: we can really build big, fast, complex systems without using OO abstractions!
- infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it's not even funny)
- inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.
In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C.
Didn't I feel the same before? That for the efficient, near system level code we can take C, and that all the fancy object thing, where the is better done in Ruby or (even) Java? So no place for C++ here? Take Wireshark protocol analyzer as example?
Gossiping
Well, the story doesn't end here. First, there are some entertaining comments on digg**. My favourites are:- Linus codes a kernel for a living, so its not that surprising that he hates C++.
- Linus is an *****, he lives here in Beaverton and the man has a big ego for someone nobody outside of the Linux community cares about.
- Ok... Who cares if Linus Torvalds hates C++. I don't really give a damn.
- another episode of "I am Linus and hate everything"
- funny that linus prefers kde when it is programmed in C++
- Personally I've evolved thinking in OO abstractions, so working with C++ is much more natural for me than C. Does that mean I'm a crappy programmer? Only Linux Torvals knows
- The STL is the biggest piece of crap I've seen in 40 years of programming. It's a graduate students project to prove one can write a totally orthogonal, yet totally inefficient, impossible to maintain, piece of crud.
Living in the past?
So, as to begin with something, what's the matter with STL? As we are gossiping in this installment, it's perfectly fine for me to say that the prevalent opinion on the Web (for example ***) is that Linus is referring to a problem from the past (around 2001 or so), when he's speaking abot the non-portability of C++. At that time the support for the C++ standard, and especially tempaltes, was very unconsistet across the compilers, and so the STL implementations could be nonportable between compilers! But nowadays even Visual C++ is quite up to speed here!Then the inefficiency allegation. I don't even want to discuss it here, because it's so old (back in time to 1998 or so). There's long refutation along classical lines from that time to be found****, if only not very entertaining, and a shorter one*****, from a practitioner's point of view - Steven Dewhurst actually wrote low level code with C++ and templates:
Just to annoy people like Linus, I've also used typelist meta-algorithms to generate exception handlers with identical efficiency to hand-coded C. In a number of recent talks given at the Embedded Systems conferences, I've shown that commonly-criticized C++ language features can significantly outperform the C analogs.
Who's incompetent?
Next comes the critique that C++ tends to attract substandard programmers, and that:... limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap.The first thought that comes to mind is Linus' "software Darwinism": in 2000 he lambasted people wanting a debugger in the Linux kernel. His argument was: I don't need any sissy that needs a debugger! I want people who understand the code as a whole! Any higher level abstraction or language (i.e. STL or C++) will make you a wimp and not careful enough!
The fact is, that is *exactly* the kinds of things that C excels at. Not just as a language, but as a required *mentality*. One of the great strengths of C is that it doesn't make you think of your program as anything high-level...But isn't this just another management whip for the programmers to keep them under pressure, so they are more obedient? A manager's trick? The Linus' software management process? I'm most hardcore of you all, so I'm the overlord ;-). In that light Linus' diatribes are only politics: he's defending the status quo.
There's also a diffrent response to the "substandard programmers" reproach I must mention here. Steven Dewhurst broght in the point, that for a C programmer C++ is so complex because there are alien idioms, methodologies, tricks, and so on*****. You would be tempted to say it's to difficult for the average C coder, but there's something else! C++ isn't just C, it only happens to be backwards compatible! When you switch from C to Common Lisp you won't be an expert instantly, but the C folks assume they can just come and start programming C++. And then they cry that it's too difficult and complex.
Summary
This time there's no summary. I was just gossiping...---
* Linus original post (admittedly taken out of context!): http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918, but I must admit, when he's speaking, he does make a much better impression!
** Digg gossiping: http://digg.com/linux_unix/Linus_Torvalds_hates_C
*** Hacker News discussion: http://news.ycombinator.com/item?id=51451
**** A typical reply: http://warp.povusers.org/OpenLetters/ResponseToTorvalds.html
***** Steven Dewhurst's reply: http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=411
I really don't understand why people are so angry with Linus when he has an opinion. Who really cares? He's a kernel developer, of course he's out of his mind. For him, there are no compromises, no sacrifices in speed for the sake of reliability or to make things simpler. Why would you listen to a guy who's day job is thinking like that? Unless you're developing a kernel of course.
ReplyDeleteBut chances are you're not developing a kernel. So who cares? Let him be. He's probably right when it comes to the Linux kernel, but for the rest of the world, what he values is not what we value. And besides, blogging about him only makes him stronger.
Well, I don't see what's so terrible about Linus preferring C to C++. I suppose it's different in American universities, but while I studied each group or lab inside of the university would have their preferred language/paradigm and would stand by it, even when they knew the arguments their detractors used were as valid as theirs.
ReplyDeleteIt was normally taken as a funny thing, and some guys would utter an 'Oh, you are an OOP evangelist' to the slightest reference to Smalltalk, and some others would say 'Oh, there come the kernel guys and their gritty little bare-iron concerns' when someone referenced C/Assembly.
Now, I understand Linus can piss a lot of people because he's seen as some kind of evangelist for the open source movement, but let the guy say whatever he wants. He does a great job in C, and sure as hell he won't complain if you do a great job in C++/Python/What-have-you.
Linus makes some good points, but if you substitute "C" with "Assembly Language" and "C++" with "C", his rant sounds very familiar...
ReplyDeleteTo Anonymous (well at least the Anon before this message): sure! That's the point, there are a lot of those stupid comparisons where one says 'My language is closer to the hardware and my code is faster' and a detractor says 'In this time and age you shouldn't need to care about memory allocation'.
ReplyDeleteIt's really academic, and nobody should care (or take it too seriously anyway).
A c++ programmer came to his C projects and pushed C++..of course he's going to be angry about it. He is correct to say that stuff because.. In a C project where the most knowledgeable coders can't review the quality of the c++ coming into the project.. and also do not know if this guy is going to actively maintain that code.. how else should he respond? This should have been common sense for the guy suggesting c++, so he truly was a moron and deserved the smack down he received. I think people perceive this as a c vs c++ religious war, which it really isn't that hard core. If you worked with Linus on a large c++ code base I'm sure he'd say something similar if someone came in suggesting D.
ReplyDeletePeople need to calm the hell down about over analyzing mailing list replies. If you are at all familiar with the LKML you'll know that over the years heated discussions happen and in the end someone wins, but it's just another day in the grind called life and no one goes home crying about it.