Torvalds uses horrible language

November 18, 2008

I have been waiting to see if some authority in the c++ community would bite and give a response to Linus Torvalds flame about how bad C++ is compared to C. Steven Dewhurst’s wrote a good response. But first, If you haven’t heard the gossip.. A while back Linus gave sound bites like:

“C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it. […] C++ leads to really really bad design choices. You invariably start using […] STL and Boost and other total and utter crap […] 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. [C++ leads to] inefficient abstracted programming models. […]  The only way to do good, efficient, and system-level and portable C++ […] is limiting your project to C [which] 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.”

You can read the whole thread here if you like.

I find it a bit chocking that a highly respected programmer like Torvalds would write such statements about the most advanced language in common use. He did not give any references to back up his claims about C++’s inefficiency or importability. He gave very little context for his views, so its hard to see where he is coming from. I got the impression reading the thread that C++ is unpopular in the open source developer community.

It’s been a long time since C had any performance advantage over C++. A decade ago The inventor of STL, Alexander Stepanov, wrote a famous article and benchmark where he debunkes the myth of the abstraction penalty of C++ compared to C. You can read the whole paper here.

The current C++ standard has been out for a decade, and today’s main compilers and standard library implementations are very conformant. So I cant imagine portability being much of an issue today. Even assuming Boost has portability problems, the library is just another 3rd part library, so you cant really blame the C++ language for it.

As for bad code and programmers. The fact that C++ has data hiding and abstraction features, and has stronger type safety than C, makes it easier to write good code. Without using data hiding and abstractions, dependencies are stronger and their number greater than necessary. It seems rather anti-intellectual to prefer more detail over more abstraction. After all, math, the purest science of all is all about abstraction. Good code is correct code, first and foremost. And performance, although important, is a secondary concern. With C++ we get the best of both worlds. Powerful abstractions and high performance.

I see no benifit to C, other than it being a simple language to learn. C++ might be complex, but not needlessly so. Every feature (well almost) is there for good reason.

Anyways, finally, here is Steven Dewhurst’s (a well known C++ author) response to Linus comments about C++. I’d love to see Linus response. Maybe he could explain his reasoning better given another chance.


One Response to “Torvalds uses horrible language”

  1. pizer Says:

    My thoughts exactly. This diatribe is one year old, though. I guess he was mostly pissed because of the newbie that started this thread. Yeah, his “abstraction penalty”-argument is moot. What’s left is the “the share of qualified C++ coders is much lower than the share of qualified C coders because of the horrible language design”-argument which is at least questionable.

    – P

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: