Skip to content

Linus Torvalds


C++ is a horrible language.

    Linus Torvalds rant on C++

    Its actually a rant on C++ by Linus Torvalds himself, the creator of Linux back in 2007. The site had since shut down but an archive version with Linus reply can still be found on the Wayback Machine.

    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.
    
    So I'm sorry, but for something like git, where efficiency was a primary 
    objective, the "advantages" of C++ is just a huge mistake. The fact that 
    we also piss off people who cannot see that is just a big additional 
    advantage.
    
    If you want a VCS that is written in C++, go play with Monotone. Really. 
    They use a "real database". They use "nice object-oriented libraries". 
    They use "nice C++ abstractions". And quite frankly, as a result of all 
    these design decisions that sound so appealing to some CS people, the end 
    result is a horrible and unmaintainable mess.
    
    But I'm sure you'd like it more than git.

    Original thread with Linus full reply

    On Wed, 5 Sep 2007, Dmitry Kakurin wrote:
    > 
    > When I first looked at Git source code two things struck me as odd:
    > 1. Pure C as opposed to C++. No idea why. Please don't talk about portability,
    > it's BS.
    
    *YOU* are full of bullshit.
    
    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.
    
    So I'm sorry, but for something like git, where efficiency was a primary 
    objective, the "advantages" of C++ is just a huge mistake. The fact that 
    we also piss off people who cannot see that is just a big additional 
    advantage.
    
    If you want a VCS that is written in C++, go play with Monotone. Really. 
    They use a "real database". They use "nice object-oriented libraries". 
    They use "nice C++ abstractions". And quite frankly, as a result of all 
    these design decisions that sound so appealing to some CS people, the end 
    result is a horrible and unmaintainable mess.
    
    But I'm sure you'd like it more than git.
    
    			Linus

    No, Richard, it’s ‘Linux’

      No, Richard, it's 'Linux', not 'GNU/Linux'. The most important contributions that the FSF made to Linux were the creation of the GPL and the GCC compiler. Those are fine and inspired products. GCC is a monumental achievement and has earned you, RMS, and the Free Software Foundation countless kudos and much appreciation.
      
      Following are some reasons for you to mull over, including some already answered in your FAQ.
      
      One guy, Linus Torvalds, used GCC to make his operating system (yes, Linux is an OS -- more on this later). He named it 'Linux' with a little help from his friends. Why doesn't he call it GNU/Linux? Because he wrote it, with more help from his friends, not you. You named your stuff, I named my stuff -- including the software I wrote using GCC -- and Linus named his stuff. The proper name is Linux because Linus Torvalds says so. Linus has spoken. Accept his authority. To do otherwise is to become a nag. You don't want to be known as a nag, do you?
      
      (An operating system) != (a distribution). Linux is an operating system. By my definition, an operating system is that software which provides and limits access to hardware resources on a computer. That definition applies whereever you see Linux in use. However, Linux is usually distributed with a collection of utilities and applications to make it easily configurable as a desktop system, a server, a development box, or a graphics workstation, or whatever the user needs. In such a configuration, we have a Linux (based) distribution. Therein lies your strongest argument for the unwieldy title 'GNU/Linux' (when said bundled software is largely from the FSF). Go bug the distribution makers on that one. Take your beef to Red Hat, Mandrake, and Slackware. At least there you have an argument. Linux alone is an operating system that can be used in various applications without any GNU software whatsoever. Embedded applications come to mind as an obvious example.
      
      Next, even if we limit the GNU/Linux title to the GNU-based Linux distributions, we run into another obvious problem. XFree86 may well be more important to a particular Linux installation than the sum of all the GNU contributions. More properly, shouldn't the distribution be called XFree86/Linux? Or, at a minimum, XFree86/GNU/Linux? Of course, it would be rather arbitrary to draw the line there when many other fine contributions go unlisted. Yes, I know you've heard this one before. Get used to it. You'll keep hearing it until you can cleanly counter it.
      
      You seem to like the lines-of-code metric. There are many lines of GNU code in a typical Linux distribution. You seem to suggest that (more LOC) == (more important). However, I submit to you that raw LOC numbers do not directly correlate with importance. I would suggest that clock cycles spent on code is a better metric. For example, if my system spends 90% of its time executing XFree86 code, XFree86 is probably the single most important collection of code on my system. Even if I loaded ten times as many lines of useless bloatware on my system and I never excuted that bloatware, it certainly isn't more important code than XFree86. Obviously, this metric isn't perfect either, but LOC really, really sucks. Please refrain from using it ever again in supporting any argument.
      
      Last, I'd like to point out that we Linux and GNU users shouldn't be fighting among ourselves over naming other people's software. But what the heck, I'm in a bad mood now. I think I'm feeling sufficiently obnoxious to make the point that GCC is so very famous and, yes, so very useful only because Linux was developed. In a show of proper respect and gratitude, shouldn't you and everyone refer to GCC as 'the Linux compiler'? Or at least, 'Linux GCC'? Seriously, where would your masterpiece be without Linux? Languishing with the HURD?
      
      If there is a moral buried in this rant, maybe it is this:
      
      Be grateful for your abilities and your incredible success and your considerable fame. Continue to use that success and fame for good, not evil. Also, be especially grateful for Linux' huge contribution to that success. You, RMS, the Free Software Foundation, and GNU software have reached their current high profiles largely on the back of Linux. You have changed the world. Now, go forth and don't be a nag.