I was reading a recent article (“Real Men program in C”) recently, and came across a link in the comments to Linus Torvalds’ opinion on the whole C-vs-C++ thing. Let’s just say he doesn’t mince words. (This is an excerpt, but it captures the flavor of the original post.)
What Linus said.
C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point where it’s much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.
In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said “to piss you off”, but it’s actually true. I’ve come to the conclusion that any programmer that would prefer the project to be in C++ over C 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.
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:
– 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. And 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.
TrustLeap G-WAN is a Web Application Server which is faster (in user-mode) than IIS 7.0 (in the kernel). G-WAN ANSI C89 ('edit & play') scripts are 5x faster than ASP.Net C#.
G-WAN is up to 38x faster than Apache.
G-WAN is up to 25x faster than Nginx.
G-WAN was started in C++ and then converted to C because of the '++' overhead. The gain was not only in footprint (currently 106 KB), but also in performances (~180%).
If you want to know what makes C++ so bad, just try virtual inheritance and virtual functions, and then compare the machine code générated by the C++ compiler with a clean C implementation of the same features (the C++ code is twice larger -and slower).
Conclusion: if you are targeting performances then you can use C++ as long as you write C code compiled with a C++ compiler.
In my humble opinion, Linus is a programmer that make systems work, and Bjarne is a programmer that uses the systems created by programmers like Linus.
There should be no surprise that system users are less technically inclined than system engineers.