Coding Horror

programming and human factors

The Problem With C++

MIT's Technology Review recently interviewed Bjarne Stroustrup in a two-part article (part one, part two). You may know Bjarne as the inventor of the C++ programming language. Indeed, he even maintains a comprehensive C++ FAQ that answers every imaginable C++ question.

Here are a few select quotes from the interview that I found notable:

C++ has indeed become too "expert friendly" at a time where the degree of effective formal education of the average software developer has declined. However, the solution is not to dumb down the programming languages but to use a variety of programming languages and educate more experts. There has to be languages for those experts to use-- and C++ is one of those languages.

What I did do was to design C++ as first of all a systems programming language: I wanted to be able to write device drivers, embedded systems, and other code that needed to use hardware directly. Next, I wanted C++ to be a good language for designing tools. That required flexibility and performance, but also the ability to express elegant interfaces. My view was that to do higher-level stuff, to build complete applications, you first needed to buy, build, or borrow libraries providing appropriate abstractions. Often, when people have trouble with C++, the real problem is that they don't have appropriate libraries--or that they can't find the libraries that are available.

Other languages have tried to more directly support high-level applications. That works, but often that support comes at the cost of specialization. Personally, I wouldn't design a tool that could do only what I wanted--I aim for generality.

I think [making computer languages easier for average people] would be misguided. The idea of programming as a semiskilled task, practiced by people with a few months' training, is dangerous. We wouldn't tolerate plumbers or accountants that poorly educated. We don't have as an aim that architecture (of buildings) and engineering (of bridges and trains) should become more accessible to people with progressively less training. Indeed, one serious problem is that currently, too many software developers are undereducated and undertrained.

In the FAQ and the interview, Bjarne comes off as a little defensive about C++ and its role in the history of computer languages. Maybe that's because the importance of C++ has diminished over time, principally for two reasons:

  1. C++ is fast but unforgiving. It was an appropriate solution for an era of limited computing resources. But we've long since left that behind; we live in an era of abundance. We have more computer power than we possibly know what to do with on the desktop. Even the naive solutions for most computing problems are "fast enough" these days. Computers get faster every day, but programmers' brains, sadly, do not. It'd be a waste not to trade some of that abundant raw power to make things easier on us. It's time to evolve up the one trillion dollar programming pyramid.

  2. C++ is designed for any possible programming task, from the lowest level to the highest. It makes sense to use C++ to write operating system kernels and device drivers. But when was the last time you used C++ to write a line of business app or website? C++ is perhaps the ultimate generalist language. Because it can do all these things, it's complicated and dangerous. Other languages don't try to span the entire range of low-level to high-level programming tasks; they simplify to attack a specific high-level problem domain.

C++ is a key historic milestone in the evolution of computer languages. There will always be a place in a programmer's toolbox for C++, but I'd argue that it's an increasingly a niche language for a very specific subset of programming tasks. The most important question to ask about any language these days isn't how fast it is, or how general it is, but how well does it protect you from yourself? Stroustrup has a great quote that says it all:

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.

Written by Jeff Atwood

Indoor enthusiast. Co-founder of Stack Overflow and Discourse. Disclaimer: I have no idea what I'm talking about. Find me here: