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.

This is a companion discussion topic for the original blog entry at:

Haha, you obviously have no idea how a compiler works and what the difference is between a compiler, an intepreter, a bytecode and a JIT compiler.

Anyway as someone way above stated very clearly C will always be used for low level stuff, kernel and drivers. C and not C++ which has nothing to do with C whatsoever. Furthermore if you want speed or small code you use C, not C++ and all the mess it generates with classes and stuff.

FYI – there is now post-tension concrete that actually makes concrete harder because it is compacted. also, there are different grades of concrete, the best using ash that strengthens concrete over time. it just goes to show the old saying is true: garbage in, garbage out.

C and C++ will always have their place for writing core libraries. and i’m a lot more comforatble managing my own memory (until i get Alzheimer’s) than some new-college grad that’s never heard of pointers. Even MS developers don’t trust the garbage collection in the .NET languages. (i can’t find the post right now…)

“But when was the last time you used C++ to write a line of business app or website?”

Hmmm. I guess that would have been last Friday, January 12 2007, when I was writing code for flight software application at a major aerospace corporation. For some odd reason, we aren’t converting our insanely huge C/C++/Fortran codebase into Java, D, Ruby on Rails, Python, Perl, or whatever the current flavor-of-the-month language is…

I’ve been coding for about 20 years, in all sorts of languages. Assembler, Java, Smalltalk, JCL, REXX, C, C++, C#, Shell, Pascal, Perl, PHP, Ruby, TCL, Eiffel, Maple, Mathematica, Gauss…god knows what else, even VHDL’s for FPGA’s. Let me say that C++ is pretty great, and infact is what I’ve chosen to use for a number of new projects.

Here are some comments on assumptions on points above:

  1. Many assume ‘higher level language’ needs to be ‘slower’. That’s just not true at all. That said, if it’s slow in C++, it’s likely your algorithm, while if it’s slow in a high level language, it’s probably that you’re using convenience classes that are poorly suited for your problem domain.

  2. It’s true that a lot of programmers aren’t formally trained anymore. If a programmer can’t work out time complexity between a Quick Sort and a Bubble Sort (really basic questions), I don’t hire them. Even if they’ll be using a high level language. I’ve seen hundreds of thousands of dollars go up in smoke because programmers honestly didn’t understand why the Java ArrayList behaved so poorly when used as a queue, and the queue size grew. Actually, change that: millions lost. High level langauges should be used for their expressive power, not as a crutch for people who shouldn’t be programming commercially. It’s ilke the comment above, “you don’t know when you’re hit”.

  3. Many high level languages are compromising in areas they shouldn’t, letting programmers be lazy. If there’s one problem with coders in high level languages, is that they don’t seem to write much ‘error checking’ code. If something like VB or C# had Design by Contract built in (like Eiffel has) forced as part of the language, I’d be happier. I do know about Spec#, and other C# DBC extensions. Really, the language should be easy to use, but also do it’s bit to enforce some quality.

  4. Vista’s way slow. I played with it yesterday and I could see delays in the icons on the start menu popping up. It’s pretty pathetic. If I were Microsoft, I wouldn’t be proud of it.

  5. C# is a nice language. I’d rather people learn Smalltalk tho. Squeak is cool.

Only in the last three years have I spent more time with C++, and I’d have to say it’s a pretty excellent language. C# is cute too, but it’s performance isn’t there. I wrote a test system in C, C#, and Ruby the other day. Ruby got 11,000 operations/sec, C# got 34,000 operations/sec, and C++ got 71,000 operations/sec. The C++ code compiled on Windows, Linux, and BSD without any warnings or code changes. It also used the least RAM.

Fast? Portable? CPU and Memory efficient? Do these things matter to anyone?

If you can’t handle the power, just steer away from it. Don’t badmouth C++ because of your inability to use it correctly.

I don’t know, maybe it’s just that I don’t like to be kept in a little box that protects me from the real world, but I prefer using C++ over all these languages whenever possible. That said, I do think that some languages are more suitable for some tasks.

Citing Bjarne, “Indeed, one serious problem is that currently, too many software developers are undereducated and undertrained.” Just go to and you’ll see that most posts come from Java and VB “programmers”.

Myself, I’m eagerly waiting for the new C++ standard that will give us more template power and some new library additions (among other cool stuff). Read about it at:

I’m wondering why people seem to think they can optimize code better than a mature optimizing compiler… In general, it’s best to let the compiler do the work.

I also keep going back to the last point on the original post: which language best protects against human foibles? My answer would be the language that is the most readable and maintainable (good examples being Ada and Python). Almost all code will be read many more times than it will be written, and any long-lived system ends up with about 10% of the total cost in the development phase, and about 90% of the cost in the maintenance phase. Draw your own conclusions…

That’s exactly why I like C# so much. It’s just too bad that we are restricted to one single platform by using it :frowning:

“The CLR will eventually destroy the class and force the connection closed, but you have no guarantee when the garbage collection on the object will actually happen.”

One of my first Computer Science instructors told me that anyone who is a solid C++ programmer knows how to program and can pick up any language out there. This has held true since I heard it 10 years ago, with perhaps the only exception being Lisp (my favorite language to play with), which many OO programmers have issues with.

The reason C++ is a good language is because it makes better programmers of us all. From low-level understanding of how the machine works by figuring out how pointers work, to high level understanding of how objects and inheritance work, C++ covers it all. After spend 2 days trying to figure out why your program keeps saying “Segmentation Fault (Core Dump)”, you learn/understand the importance of memory/pointer management. Struggling to write a linked list, and then learning about the STL makes you realize how important reusable code is.

Sure C++ is very difficult to learn and understand, but once you do, you have top to bottom knowledge and understanding of how a computer works. For all its faults, C++ should be a language every programmer has in his/her toolkit.

My $.02

C++ is difficult and for experienced programmers, experience at least with C. You can do whatever you want fast. But it is not for everyone.

Daniel: You can code cross platform with C#, Mono has come on leaps and bounds. You do have to put the extra effort of making sure your code is fully compatible with Mono and that you don’t use anything windows specific. You don’t get anything for free :wink:

Jeff: I whole-heartedly agree! C++ is a great language for hardware interaction or even for making a component that has a need for the most performance possible, but its power and flexibility means you have to take more control and responsibility over everything. More recent high level languages like C# take some of that power and flexibility away, but with less under your responsibility to directly control your productivity is greatly increased and the language/framework can protect you from many common mistakes.

Strangely, in my feedreader (Newshutch) the whole article references C and not C++…

There is another (than MS) C# compiler in existence:

But alas, whatever the language, there will always be cases of “(accidental) use of the ordnance to hurt yourself”.
Some languages protect you more, many protect you less, but incorrect code is always incorrect code.

there’s a new language out there released just a couple of weeks ago called “D”. It offers performance and flexibility of C++ and high level features like garbage collector. Syntax is very similar to java and c#.

a href=""

Is it just me or has the bitchiness level on this board has gone up considerably in the new year? Jeff writes an entry on Vista’s search feature and everybody and his brother jumps down his throat for being pro-ms.
He runs a post about C++ and it’s relationship to newer languages and all the C++ people flip out and kick in condescending overdrive.

“Programmer laziness” is the dumbest phrase I hear on posts these days. The fact is you can get considerably more done in a given amount of time with the “cute” languages like C# and Java than you can with C++ or C. It’s easier to recruit or train people in them to maintain the code. If you are writing an application that lends itself to such a language/platform wtf would you not use it?
I don’t suppose any of you non-lazy types would bother to go to Ikea when you need a new coffee table. I bet you head out to the woods to chop down some trees and assemble it yourself. Damn you’re cool. I’ll just sit down with my lazy-self, kick my feet up on my new coffee table and drink a beer while you “real” programmers are off in the woods fighting with bears and chopping down trees (no chainsaws, just axes).
Of course you wouldn’t rewrite all your legacy apps in a new language that makes no sense. Writing a whole new business application in C++ when C# or Java would do just as well? Well that’s just a waste of time and money.

So C++ was a step in the wrong direction if you want a general-purpose programming language. For most tasks its’ complexity is harmful.

Still, new mainstream-languages like Java and C# adopt the C and C++’ syntax, the type system, and control structures. Maybe it is time to realize that all languages that stems from C are broken?

“One of my first Computer Science instructors told me that anyone who is a solid C++ programmer knows how to program and can pick up any language out there. This has held true since I heard it 10 years ago, with perhaps the only exception being Lisp (my favorite language to play with), which many OO programmers have issues with.” --Bill

I’m glad you mentioned this. Maybe it’s just me but I don’t sense that Bjarne values productivity. If you can do C++, you’re going to be able to spit out an web application using Ruby on Rails or ColdFusion in no time. But if you try doing it in C++, chances are one of these non-highly-trained-programmers are probably going to crank something out before the master C++ person. It’s almost like he’s arguing an experienced plumber should keep welding copper pipes together instead of using those fancy sleeves where they can just quickly crimp together 2 pipes. It’s important to know the basics but don’t run away from productivity lest you want to be out of work and out of business.

hotdogs: D-1.0 was released couple of weeks ago. D itself lives for dozens of weeks now.

TheGeoff, so you don’t agree that there is an increasing number of undereducated programmers, and that this is caused mainly because they are getting accustomed to have important tasks done for them? Read what Bjarne said in the quoted snippet, it’s all true.

Like Bill Watts said, competent C++ developers can be competent in other languages quite easily, while it’s not true the other way around.

I’m not saying I hate languages like C# (but yeah, I truly dislike Java and VB) but I’d say it’s healthy to remain competent in languages like C++. It actually seems they put time to design C#. But if you’re into the Managed stuff, I’d recommend getting into C++/CLI.