The Problem With C++

January 12, 2007

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.

Posted by Jeff Atwood
171 Comments

I would agree with Tragomaskalos, where "modern C++" doesn't have C arrays or fully-explicit memory management (it is still somewhat explicit, as you can discern between a single-owner or shared ownership strong reference, or a weak reference, for example). You don't go anywhere near a "delete" statement, and buffer overflows are a rare occurrence with vectors and such.

The much hated C++-style casts are at least greppable (and I find their ugliness to be a *feature*, you know something's awful when you see one!) as well as more accurate (static_cast does notmagically and silently turning into a reinterpret_cast, which would most likely introduce a bug, for example).

You still have the lower-level C-style constructs available, for those times you really need them (which is just about never, if you're not doing system programming). One could say that not having them at all is probably best, but I find idiots somehow manage to write crap code no matter what language you give them, so it might as well be a more capable language.

This way, you can also notice the people with blown off legs and fire them. ;-)

Pierre Phaneuf on January 16, 2007 4:35 AM

C++ is just C with object structures, I'm guessing all C++ compilers actually still at some point output C code.

Personally I love C and C++. Yes its complex, probably more complex than is really good.

Also pretty much no one uses it, but its not really the languages fault. Blame it on Microsoft, no one wanted to write MFC applications, and Microsoft openly ignored the standard, and implemented a lot of crap that people didnt/couldnt/wouldnt/shouldnt use.

Who's got time to figure out how to write code in a language that doesnt have a standard implementation that can be used to build real applications. MFC was just too hard, weird, too Microsoft -- it killed the language.

C# is just Java with the names changed to protect the lawyers, I dont consider it a derivative. But I like it, even though I dont use it.

Mostly, I find PERL, AWK, Python, and other scripting languages get it done for me these days. Its just easier, and most stuff i want to do I want to automate and a GUI is in the way.

I still love you C++, but your time has passed.

shooby on January 16, 2007 4:37 AM

"But when was the last time you used C++ to write a [...] website?"

I've written several websites using C++. For example an SMB search engine. It is very good at integrating things - an HTML template library, SQL library, CGI library.

"Because it can do all these things, it's complicated and dangerous."

Dangerous links to buffer_overflow. That's really only a valid criticism for C and for stupid programmers. C++ has std::string and std::vector.

Tim on January 16, 2007 4:40 AM

I guess another way to look at things these days is that with so many RAD desktop/web software being developed, a modern language targeted for that end point is needed.

Low level work requires C/C++, but these days more work is done at a high level (i.e. Writing an AJAX web application, rather than writing a web browser in C++)

Really this topic shows more about human psychology!

With people:
* Defending their choice of language
* Taking digs at other language
* Attacking each other

When deep down we all know the basic truth, with is:
* There are different programming languages
* There are different types of software to be written with those languages

There is no right or wrong, only different choices with different outcomes.


Peter Bridger on January 16, 2007 5:08 AM

You are a fucking idiot, c++ is supposed to be for expert programmers only because noobs like you dont need to use it. Youre the stupidest person i've ever seen, or read.

C++ coder on January 16, 2007 5:41 AM

There sure is a lot of defensiveness around C++, but that's already been pointed out.

I agree that C++ has very few uses nowadays where C# (or another common language) would be a better choice. But Stroustrup's point about uneducated programmers is valid. As far as I'm concerned, language is irrelevant compared to skill with programming, and we have too little skill going into increasingly complex problems.

Ryan Patterson on January 16, 2007 5:54 AM

This whole topic is laughable. About every month or so the VB and Java camp spit out propaganda against C/C++. This time because Ruby has Java on the run.

Let's take this article's argument even further. Why use Java? It's harder than some other languages. The simple fact, which Stroustrup made clear, is it encourages specialization.

Look at Java, for example. As long as a Java application is idle 99% of the time it's ok to use Java. Otherwise use C/C++. That's the reputation that specialization awards.

Stroustrup is clearly frustrated with the state of Computer Science in academia. Most universities switched to Java in the classroom about 7 to 8 years ago. Not because Java is a better language but because the professors got lazy and didn't want to spend anytime teaching the C++ language. This narrow minded philosophy has lead us straight to where we are now. A small army of Java disciples suffering from something akin to C++ envy. Now we have to suffer with things like slow phone systems 'proudly' written in Java.

Graham

Graham on January 16, 2007 7:10 AM

Give me a language that is better for real time 3d graphics programming, and I will gladly use it. Not everyone has moved on to the web.

Mike on January 16, 2007 7:22 AM

A number of people seem to be saying the same thing and that is, C++ isn't the problem, the programmer is the problem. The argument seems to be if you can't solve your problem in C++ then you aren't good enough to use it.
I think this line of thinking is generally one that stunts progression. The problems we are trying to solve today are, arguably, many orders of magnitude more difficult than those we were solving 10 or 20 years ago. When C++ was created did anyone think of desktops with multiple cores? Probably not. Given this increased complexity, perhaps C++'s expressiveness is not enough anymore. C++ is not going anywhere due to legacy code, however when making a new project one should think hard and long about what benefits the various languages will give them. To put it in an analogy, construction has come a long way from slave labor, now we have giant machines to do our work. They can move in a single shovelful as much as a hundred men can. They move a bulk and of the problem and then we use smaller and more refined tools for the other parts.
I don't think making languages 'easier' is meant to make less skilled people able to program, no, I think it is meant to let experts solve more complex and interesting problems. Writing an IRC client in C++ is one thing, however building a large, fault tolerant application that needs to have defined state throughout its lifetime is different, and I would not like to do that in C++.

orbitz on January 16, 2007 7:35 AM

One thing to also remember with all of these languages, is marketing.

When .NET, which I am using to encompass C#, et.al., has Microsoft's marketing team behind it, how many "new" programmers are going to head to SmallTalk or Java? At lot less.

When Java has Sun behind it, plus their other Sun Studio product which includes C/C++ for free, how many of the left over "new" programmers are going to head there? Not quite as many.

That said:

When a business needs to have an B2B web service and web protal created in 2 months, who are they going to want to work with AND add supportability for any other programmer to step in at anytime? A C# ASP.NET programmer who can turn out that app in possibly 1/2 the time or a C or C++ programmer who can maybe get it out on time?

What if a cell phone manufacturer needed a new GreenNose driver that is going to blow away the competition and make it to market before their biggest competitor? The C# programmer who might be able to fit the app on the cell phone's limited storage space or the C programmer who can make it fit and leave room for that spreadsheet app the other department is working on PLUS crank it out in half the time?

I've said it before, yes the tool may do the job, but is it the right tool for the job?

I totally agree that knowledge of other languages is important, but I also agree that it isn't necessary. I can read C, C++, Java, or any number of other languages, and with time, could even code in them. Anything can happen with practice AND documentation.

One of the other things that makes MS technologies "better" is the fact of support. They have excellent documentation, support forums, training, and a user base that rivals any other language produced by another company or by the open source world. This a cannot be denied.

John Baughman on January 16, 2007 7:55 AM

It seems to me, there are two types of "languages": a) of the Turing camp (the FULLY ORACLE-SQL-Persisted-SWI-Prolog and ASSEMBLERs), and b) the fast, straight, bladed procedural (compiled) languages ala C/C++/Haskell/Ruby/Most_LISPs/Mercury..u name it. The basic end-to-end-runtime system, buddy, that's the very idea behind every language philosophy. And C++? Well.. SEX. Yeah, sex, sex, sex, sex, sex. The easiest way to overcome a problem is to make it a bit more.. bisexual. Add libraries. Mix it, blend it with stuff like LLVM, rt_ctiny()...even Factor..

No, bytecode seems to be so...i dont know...rude. I mean, something like a C# parser, or a Java one or VB over a bytesomething....yeah whatever

i gotta go, oh happy new year ! :-)

Patrick Down on January 16, 2007 7:57 AM

I work 50/50 C++ and JavaScript - C++ simulation models and an XUL based front end. Prior to that I've used Java both for both server and UI work, and a bit of C, Fortran, Pascal, various assembler, XSLT and Matlab. The use of C++ components with a scripting front end is not uncommon - most of Mozilla's products are defined that way, as are many COM applications.

For modelling and simulation, if you have something processor heavy it's likely to be mathematical. A good programmer can write Fortran in any language - well thought out algorithms operating mostly on primitive arrays. For that kind of code, with Java 1.4 you got better performance than MSVC++6 C; now VS2005 C is better than 1.6. C++ using stl fares worse than Java for tests such as SciMark. This is for modelling, not real-time simulation.

One of the modelling systems I've been called to work on cost 500,000 UKP per year in processor hours (the company was renting a legacy mainframe), so unless you're a multi-millionaire we're not in an era of abundance. On the other extreme, OLPC is a 100 dollar platform so again requires tight code.

Once you stop writing Fortran (and most sane people want to), the performance hits you get with Java or C++ seem to come from exploiting OO's information hiding, so the compiler is not able to optimise across objects. Sometimes trading hot-spot optimisation for whole program optimisation pays, sometimes it doesn't - for example inlining the most common case at runtime. The Fortress language, which runs on the JVM and is targetted at MS, is addressing this by flattening the program; I've also had success using model-driven development pipelines for generating flat code from high level maths models.

One weakness in C++ is that its templating system is not a very good model for meta-programming; Java and C# don't even try, so there's more external code generation options. Object oriented languages also have introspection and reflection, which C++ lacks, so I've ended up having to add them to every large C++ system I've worked on.

WRT RAII and garbage collector scheduling destruction, C# provides the 'using' statement that gives similar scope-delimited resource life-cycle semantics. It's not a hard problem.

I don't see C++ moving from realtime simulation yet (and that includes many video games, though there is use of scripting languages for AI and overall gameplay etc.) - it does most of what you want well enough, and lets you optimise for a traditional machine - until it's pushed off by a language that can handle multi-core processors better.

Pete Kirkham on January 16, 2007 8:39 AM

Sorry Jeff; While I usually agree with everything you say, you've totally missed the boat here.

Armen on January 16, 2007 8:40 AM

If you use source control, you have to see this YouTube video! ROFL!

http://www.youtube.com/watch?v=msDuQoKqysw

Ned on January 16, 2007 8:55 AM

I like C# a lot too, but it by no means replaces C++. There are a number of things that you can't do in C# that requires you to do a p/invoke to C++ code. This is especially true when programming for when programming in C# using the .NET Compact Framework on a Windows CE device.

Scott Allen on January 16, 2007 9:35 AM

Jeff, are you just writing these pieces just to sit back and laugh at so many whacked-out responses and get your page rankings up?

It works!

Steve on January 16, 2007 9:59 AM

@Steve

You are incorrect. That is not garbage collection but a simple parent-child relationship in the Delphi VCL. It is present in nearly every GUI library I have used, including Motif (C), VCL (Delphi)and Qt (C++).

The parent-child pattern is a paradigm common in many GUI toolkits and has nothing to do with garbage collection.

Ian on January 16, 2007 10:25 AM

The largest problem with C++ is that it is too easy to make mistakes. People say "You must be a competent programmer, then that won't happen", suggesting that they are such a competent programmer. NO ONE can just write bug free code, particularly in C/C++. The OOP system gives a facade of high levelness (leading to misconceptions such as a GC and safety), but really its just a macro system. The odd bit about this macro system is that it didn't really do stuff that had been repetitious in C code before.

The other problem with it is that the 'proper' expression of solutions tend to be much longer than the dumb ones, and tend to have bad interfaces to boot. Worse yet is the tendancy towards preoptimization - because you can, you do. In the end you get longwinded, improper, preoptimized code.

Except for the preoptimization point, the previous paragraph may also be applied to such languages as C# and Java, which force upon you the OOP model as well as longwinded expression of simple concepts.

PS - that thing on fortress above, It does look like a very interesting language, but it doesn't necessarily target just JVM. That's just the initial impl. They are going to target machine code, and ramp up performance.

mgsloan on January 16, 2007 10:36 AM

How can I resist adding my own comment to this burgeoning list when everybody else and their mother has already chipped in with their two cents? I have been writing embedded code for years. I do as much as I can in C, occasionally I have to deal with assembly language. C++ never appealed to me, I never found any advantage. Of course, most of the stuff I write is pretty simple minded.

Charles Pergiel on January 16, 2007 11:04 AM

The C++ programmer comments are quite interesting. None seem to remember why programming languages exist.

They exist to do useful things for PEOPLE.

PEOPLE. Remember those things?

Sometimes I need a power screwdriver with 12 specialty tips plus a dremel tool with a set of plans to do a job. Other times, a hammer and some intuition will do. You could put the dremel, drill and plan holder and pencil holder into one tool much like C++ tries to put everything into one tool. Anyone out there own anything like that?

As for complexity, they discuss it like it's a *good* thing, rather than simply an occasionally unavoidable thing. I chalk this up to machismo rather than intelligence. In humans, intelligence expresses itself as using the easiest, most appropriate tool for the job.

So I'll stick with generic freely downloadable C# or VB (which at this point are more or less the same) which run on that much hated, and ubiquitous Windows OS for most work and save c++ for those ever fewer occasions when it provides cost-effective utility.

Cheers!
Ian

ian on January 16, 2007 11:21 AM

Klingon programmers incoming!

"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."

"a programming language isn't dangerous. an uneducated programmer is dangerous. if you can't program well in something, either better your skills or stick to something you know."

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

All programmers make mistakes, Klingon programmers just don't admit it. If you use a great language, you'll make fewer mistakes whether you are a great programmer or not. Proper type safety (no memory corruption or segfaults) is something we want for 99.9% of everything - and for the rest you want assembly! We don't even have to sacrifice very much efficiency, for instance Eiffel and Ada can be written to be as fast as C if it's really that important.

Harald Korneliussen on January 16, 2007 12:14 PM

It's all about Ye Olde Fortran.

64bytes on January 16, 2007 12:31 PM


Well, with 110+ comments, this will likely be lost in the haystack, but here goes...

What a bunch of arrogant, puffed up assholes most of you are. Nothing like stroking the old ego, huh? Or the classic, "In my day, we had to...". All the talk about being threatened by C++, and yet, the mighty are freaking out that C++ is not the be all, end all. Give me a break.

Now, of course rigor and hard science disciplines should also exist. And they should set a very high bar. As stated before, Doctors, Engineers, and Scientists should not be rolling out of weekend course. I don't think this was being proposed by the original post.

But, I would put forth the example of the Web. Here, through HTML and other easy means, a wealth of wonders has been drawn out from the average person because the technology that was for so long only available in the hallowed halls of academia became liberated. In case you couldn't see it from your Ivory Towers, this is a good thing!

Imagine, a bunch of pompous cocks bitching about Gutenburg's press. "Oh, look! Now every half-wit with an opinion will be publishing books! It's outrageous! You should have to spend years and years in a monastery, learning to painstakingly illuminate by hand!".

Here's some advice: Step away from the keyboard and go do something you've never done before, and enjoy the wonder of being a novice, discovering new and interesting things. It'll do you some good.

The Foo on January 16, 2007 12:45 PM

I'm surprised that no one has brought up the side by side comparison done with Raymond Chen's Chinese/English dictionary reader. Jeff even blogged about it:
http://www.codinghorror.com/blog/archives/000299.html

Yeah, C++ will perform better than C#, but productivity-wise, it sucks. When performance is a primary concern and you've got some intensive tasks that the application will be doing(games, drafting software, etc), then of course C++ will be the way to go. However, that enterprise web application will be better off written in C# due to the huge boost in productivity and negligible performance penalty.

Marty on January 16, 2007 12:59 PM

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 ;)

I know I know...I just doubt it works properly as C# / .Net have been designed for Windows (and possible Windows Mobile). Java has strong support for Linux with Free Application Servers, Web Servers, Database Backends etc...is C# / Mono really on par with that??

Daniel Lehmann on January 17, 2007 4:49 AM

Nice post and few daring conclusions :). I agree with some observations but not all, few points which I totally disagree..

First commenting about website development using C++ is inappropriate as there are alternate language for it. C++ is a computer programming language and has nothing to do with how to render an webpage. Although backend HTML render engine in most probability is C++.

Secondly, C++ is not dead. Most of the gaming engine, computational apps, libraries or simulation code is in C++ (most of it).

Thirdly, I am not sure we are in the era of abundance, philosophy that you have presented - being in era of abundance allows us to design lazily is not an appropriate argument. Why don't I see my machine being booted under 5 sec and OS running blazingly fast?? Our task are still the same - documenting, emailing, browsing and some business app. Still we are slowing down everyday.

I don't deny the need for C# or similar language but whenever you have to build any business app - most of the time is C++/C, just to ensure you can do what you want but not limited by some other constrains :)

-km

Ketan on January 17, 2007 6:33 AM

" "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."

Not sure what the definition of "line of business" is, but I don't think flight software qualifies. You're doing the exact kind of program most posters recommend for C++. It ain't like no web site.

Brad on January 17, 2007 10:35 AM

There is nothing like C++ to start a flame war.

Why does everyone forget about people who write programs that make heavy use of numeric computation? Many of these people are still writing in Fortran. Though, C++ is great for this too.

Good static analysis can really help C++. Every criticism of C++ is true and almost all of the time that's how it was designed. It's kind of like calling a dog a dog... You should already know what it is.

The optional garbage collection in C++09 looks interesting.

Imho, it is usually poor design and coding practice that leads to unnecessary complexity, not a programming language. You can make a mess in Java just as quick as you can in C++.

Using more than one language in a project is good [tm].

ChrisD on January 17, 2007 12:23 PM

I have 7 .NET applications idling, including Sharpreader (ugh) and a couple of instances of Paint.NET. No percievable slowdown in any of my applications, .NET or otherwise. Even when I start loading files (with Paint.NET does the fastest I've seen btw) or doing process intensive task there is no slowdown relative to a native application.
My conclusion? I would have no problem running managed applications if people wrote more that I wanted.

[ICR] on January 18, 2007 2:12 AM

Games will remain in the domain of C++ for a long time. Microsoft may have it's agenda trying to push C#, but there's still Sony and Nintendo out there. The one common denomator is C++. Game companies want to be able to get their game on as many consoles as possible, which means portability. If a game developer was geared towards C#, then they'd cut themselves off from the Sony and Nintendo markets.

However, scripting using Java/Python/Lua will become more and more important. They won't replace the C++ code, but will augment it. And there's some techniques you can adopt to reduce the garbage collection boogeyman when the language is used for this specific purpose.

I've worked with C#, Java, Python, Lua, Visual Basic, etc. At the end of the day, I come home to C++ because it does what I want and need it to, without sacrificing performance or any overhead to garbage collection. Even if that means taking a bit more time, it will get me to the goal.

Blaine Hodge on January 18, 2007 6:19 AM

And, well i really like the whole Plan9/Alef thing. It's open, small, you can understand it and you can modify it at any given time. Very, very easy to use...That's the real power of C and C++. The environment.. . And the possibility to make that conversation between you, the compiler... and the OS. I mean it’s so transparent ... C/C++ is not a bad thing but you need the right environment, the compiler and the OS must be 1 really. That’s the “problem” with commercial systems like Windows... They're interfaces, politics, philosophies and a million other things.....but they can't really make the subjective connection between the programmer, the language, and the OS. I don't know, maybe the first step should be to make the end users - programmers...

Patrick Down on January 18, 2007 9:40 AM

Cement? Why use cement? I find that chewed gum and masking tape take care of most problems just long enough for it to become someone else's problem.
Confucious say: If it's not my problem it doesn't exist.
And remember - Ideas are dangerous. The more usefule the idea, the more dangerous. Especially in the incompetent hands, you twiddle-fingers.

Joe Cartoon on January 18, 2007 11:31 AM

Maybe the first step should be to show programmers how to post responses only once.

If you code like you post, we're all in trouble.

Thanks ^2 Patrick, you code-mumbler.

Joe Cartoon on January 18, 2007 11:36 AM

Actually, Plan 9 from Outer Space is my FAV! And if it wasn't for my dashing digits you wouldn't have software gems like MS BOB. MS BOB rocks the muthafu@#ing house, y'all! Yeah!
Oh, my party bong is empty, be back in a flash.
Hey, I just realized that I can stop writing, and go about my business and you'd never know! Wow, this is pretty neat! Nothing like that IM crud. It's like so needy! Always ringing when people write stuff, it's like so instant, you know? maybe the first step should be to make those people that write the IM apps - programmers...

Patrick Down on January 18, 2007 11:45 AM

The problem isn't that C++ is difficult, because I've started programming in Pascal, then C/C++, then Visual Basic, then Java, and now I'm loving C#.

The actual problem is educating developers. Everybody is taught the same basic things at college when it comes to programming. We need to refine programming degrees, and take the novice developer further than the text book.

I think Java has the right idea when it comes to education -- look at the Java tutorial on the Sun Microsystems website. We need a C++ encyclopedia.

Nick on January 21, 2007 11:38 AM

I see a lot of comments of the form "C++ can't do this as well as language X". C++ is available for all platforms. That throws out anything from Microsoft. C++ is a fast compiled language. That throws out all scripting languages. C++ can do basically everything you want, including numerical computing and writing operating systems. That throws out Java. C++ does everything, and does it fast. Does that matter in *all* cases? Obviously not. But we'd be hurting if we didn't have C++.

lmf on January 22, 2007 8:30 AM

I can still remember programming the 65802 chipset in assembly language in the early 1990's and thinking "hmmm... that C++ looks a bit too much of a high level language for me."

Since then I have been dumbed down so much, that .net's intelli-type programming rubbish, where in a lobotomised state the GUI autofills my thought process for me. "Imports Microsoft.Thoughtprocess.Global.Domination" doesn't even register on the "is that the best way to do this?" anymore.

After 25 years and seen a lot of different stuff and people, and the only thing I don't like is language snobbery. The one thing I've learnt is that it's the right tool for the job.

Long live C++ (for device drivers..)

p.s. Some dude wrote that C# would blow your whole body away if you got it wrong... I have two words to say to about that :managed code

Steve on January 23, 2007 2:19 AM

IMHO, For a very low level, c and c++ (not including OOP) is efficient, examples, controls of some hardware signals, communication devices etc.

Logical application, c++(OOP) is the best approach such as middle wares programs.

For Front-end GUI, I think most of the people uses windows platform,which what i think that C# comes in. From c#, as long as you can communicate with those middle ware system and have a good GUI, you are done.

mysuface on January 25, 2007 7:21 AM

RE the argument that systems are super fast and ultra powerful, so we can compromise speed for flexibility.

Sure, that works in some very limited cases (basically the web). But if you seriously think that your computer is fast enough, and you're ok with slower apps, then you're showing your age. My system is brand new, with high end components overclocked to the maximum. This system is WAY too slow. A little piece of me dies inside every time java starts loading...(pet peeve, sorry)

As I said, there's a time and place for C#/Java/VB/etc. When you need a quick app, those can't be beaten. But for any serious coding, performance is as important as development difficulty. After all, you write a program once, you execute it many times.

mark on January 27, 2007 8:04 AM

Forget all these languages I'll stick to Brain fuck.
http://en.wikipedia.org/wiki/Brainfuck

pool_boy on February 6, 2007 11:15 AM

Bjarne Stroustrup is generous to defend C++. I don't know what's supposed to be wrong with rationally defending your own creation when it is being attacked. We only use "being defensive" with criticism when there is nothing to defended against.

I recommend that everyone visit his personal website and read his publications. Everything in C++ is rigorously and logically justified. The few problems that persist are openly admitted and will be fixed in C++ 09. C++ will be the norm for a very long time because there will always be good programmers to defend it.

Emery on March 7, 2007 12:57 PM

"Programming languages should protect you from yourself."

What are you talking about?

Programming languages are tools to force a brain-dead machine (i.e. computer) to do repetitive tasks over and over again. Dude, you READ "Code Complete".

All you are asking is for some feature made by some really bright programmer (probably in a low-level language such as C++), for instance -- your wish for "case-insensitivity", to teach the computer catch your errors by assuming it knows what you REALLY mean.

Look, the computer will NEVER replace smart people - EVER! (If it does, people are in a world of hurt.) You have to be smarter than the thing you are working with. It is not any programming languages fault for "sloppy thinking" or "programming errors" IT WILL ALWAYS BE THE PROGRAMMER'S FAULT.

"Programming languages should protect you from yourself."

All that is will be the smart programmer carrying the load for the average programmer (i.e. dumbing down the job). This will create a hierarchy of the real smart guys (who WILL be paid the big bucks) so the not-so-smart ones can do relatively simple tasks (and not get paid the big bucks)

Don't believe me -- I have one word: LabVIEW.

This graphical language was supposed to take over the world -- because it made "everything SO much easier" than those "complicated text-based languages"

Yeah, right

Luckyleo on May 25, 2007 8:23 AM

"The idea of programming as a semiskilled task, practiced by people with a few months' training, is dangerous."- Bjarne Stroustrup

I agree 100% with that statement. I see a lot of guys hurrying to develop applications without actually having obtained any good programming skills, and they come up with some really crappy and non-portable codes (especially in the geographic location where I live in). Here is an FAQ of C++ Programming forum that I maintain:
http://prokutfaq.byethost15.com/CPPFAQ

Papu on June 7, 2007 11:21 AM

Just quit you whining an use Ada.
It will protect you from YOU.

jt on August 30, 2007 8:14 AM

I read an article titled "Problem with C++" by Jeff Atwood here: http://www.codinghorror.com/blog/archives/000768.html

I agree with some of his ideas and not with some of others. The point is I agree that C++ is complex and too cumbersome but i say that from a totally different point of view. This is what I have commented on his article:


==== Indeed, one serious problem is that currently, too many software

==== developers are undereducated and undertrained.

Well, Bjarne is 100% right about it. I am simple Science Graduate and when I meet programmers
carrying degrees like Master's of Computer Applications, they still don't know about the difference between a Pointer and a Reference in C++, they just don't have much understanding on Pointers and Arrays. They just create some softwares in VB and .NET and they call themselves Sr. Software Developers. some of them say VC++ is a better language than C++ and in their C programs, most of them use #include conio.h and they say it is from ANSI C Standard Library :-\ WTF ... they just move buttons here and there in VB and call themselves programmers... All of them say Hackers means Criminals, utter nonsense and nearly all of them use Windows. see the connection ?

Not only Bjarne, even Joel Spolskey is serious about the under-trained programmers: http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html

and even I think he is right. This is simple, plain common-sense that a person who never ever understood C or C++, is simply not a programmer, He can never be. C is hard, C++ is harder and complex. Dumbing down the education is just stupidity and that shows Government has not employed talented people to revise the education system of your country. Remember the "Segmentation Fault" that does not even tell you where the error is ? and then you set aside the program and keep on thinking where the error could be and at the same time you also think about the way you wrote the program .. thinking at 2 different levels, making work harder and most Post Graduate kiddies break under such circumstances, they run and cry and say C and C++ are bad. Understanding C or C++ is definitely going to make you the real programmer, I am into this field from last 2 years and I never met anyone, in person, who can call himself a programmer (because nobody of them knows the C or C++ well). You can keep on wandering into Java, .NET , Ruby or all the easy fun things and keep on believing that "I am into Applications Programming, Managing Memory is a poor idea, Processors are fast RAM is cheap" and miss on all the knowledge we call "Programming" or "Computer Science". There is even a connection between all these high-level programmers and poor algorithmic knowledge, they just don't possess enough idea about algorithms, the key concept in programming and as Niklaus Wirth said:

Algorithms + Data-Structures = Programs

and he is right. you the high-level programmer is just a kid, you are wrong, If you can not do C or C++, do not enter into Software Development. It will never be enjoyable to you and even after 10 years into it, you will still be a kid because you will never try to understand the essence of programming. You are poor programmer then and you know about that every single moment you think but you hide behind the self-made lies and cry over C and C++. Bjarne calls you an undereducated and under-trained programmer but I call you an under-minded programmer, the programmer who intentionally does not want to learn, who intentionally stays away from pain and hardness, who fears and then cries over for nothing .... you are damn stupid waste on human-life and on Nature. You better go and do something other than programming. Programming is about diversity, about hardness and playfulness and it has to do with the ability to solve problems and you under-minded are not the ones who can cal themselves programmers. shame on you...

(NOTE: I am not saying C++ is not complex, it is complex and monstrous and saying C++ is plain bad and Ruby/Java are good is a complete non-sense. The Programmer who agrees with this idea just don't have clue on what Programming is all about. It also means, he needs to learn more , He needs to put more time into Programming and he also needs UNIX way, IMVHO)

arnuld on September 20, 2007 2:12 AM

Common C++ still has tremendous server side applications, imagine a firm processing a millions of trades a day?? u can't expect a bloody garbage collector to kick in..

Anand on September 27, 2007 3:17 AM

I really try to learn and use Ada time to time, but my head aches from reading Ada code, so I stick with C++.

Zanusi on October 4, 2007 1:31 PM

C++ is incredibly unproductive. It's crushing stones. With copper hammers.
I'm doing it for a living, 8 hours a day. It never ceases to amaze me that some more complex algorithm that takes perhaps an hour in a highly expressive language like Lisp takes 3 f*cking weeks(!) in C++. Stroustrup talks about efficiency in every second sentence of his horrible book but completely fails to understand that the first way to make (large) programs faster is to give the programmer more expressive tools. Micro-optimize my arse. All large C++ programs I've seen have performance problems, which stem from the fact that large C++ programs become much larger (in LOC) than necessary, terribly convoluted, bureaucratic and hard to refactor. No thanks.

no way, jose on November 8, 2007 2:05 AM

"it's dangerous"? a programming language isn't dangerous. An uneducated programmer is dangerous. If you can't program well in something, either better your skills or stick to something you know.

Maybe it's because I've just been reading Don Norman, but this screams "It's not the designer's job to make the right thing easy and the wrong thing hard."

In a sense he's right, of course. Programming languages don't melt servers, programmers melt servers.

But if there's no reason to use a server melting language, using it because it's the "language of choice" is like using a battleaxe to cut through a plank; impressive, and normally memorable, but there was probably an easier way to do it better.

deworde on November 8, 2007 2:26 AM

Oh, and I'm not word perfect with C++. According to arnuld, I should therefore quit my job and become a taxi-cab driver. At 23, this seems like a drastic step.

deworde on November 8, 2007 2:29 AM

Of course, as I've just noticed arnuld appeared to use IMVHO without humour, so he can be safely ignored.

deworde on November 8, 2007 2:31 AM

fiblist = 0 : 1 : (zipWith (+) fiblist (tail fiblist))

Heh. Try that with your objects and callstacks and manual memory handling.

haskellnerd on December 20, 2007 2:38 AM

anyone gets the english to C++ translation?

If not, I can teach them what it really means since they're too dumb to understand that c++ is a language just like English.


How could they miss that? We are talking about computer LANGUAGE. Do you understand the meaning behind that word? To communicate with. Like how we code to the computer and it reacts to our code. Code = our aid in language translation to computer language. Machine language = all binary data the computer naturally reads and understands. Without researching this, I would geuss that machine language is telling the system to give power to certian area based on 1 being on 0 being off

Luigi on April 11, 2008 2:59 AM

as far as i can tell the times of java being 20 times slower than c++ are gone. 8 years ago when java 1.1 was around and interpreters weren't coded so well that was true. nowadays java is really fast. also numbercrunching apps were really fast in java. the problem of those benchmarks are, as i have seen a lot when at university is that a java program outperforms a c++ program when the coder is very skilled in java but only has some c++ knowledge. you can make far less mistakes coding java and you really don't have to worry if someone overloaded your operator, multiple inheritance or other messy stuff in c++.

still c and c++ are very powerful languages but in the time i code applications using c++ i nearly have coded the same application twice in java. it's a valid point if you argue with companies because manpower is very expensive in smaller and medium sized companies. imagine you have to tell your business partner "well you can have it in c++ and it't cost 30k developing costs +5k server hardware" or "15k developing costs in java +7k server hardware".

well, just my 1.2 eurocents (2 us cents)

schmirgo on April 25, 2008 7:46 AM

many of you i think have that Joel Spolsky mentality that there is nothing but web applications out there when in fact there is the same if not more desktop applications being either written or maintained.

what about medical imaging software thats just starting to take off? what about 3-D graphics programming and virtual reality? if you can think of anything that does any number crunching whatsoever C++ is your best choice.

currently things written in C++ includes but is not limited to the following:(and this is just things that i have gotten off the web)

* Acronis TrueImage
* Age of Empires
* Autocad
* C# Bytecode Compiler
* Doom
* Exchange
* Final Fantasy
* Firefox
* Flash Player
* GCC
* GDB
* Gnome Desktop
* Google Search Engine
* Half-Life
* Illustrator
* Internet Explorer
* iPhone
* Java Compiler
* Java Virtual Machine
* KDE Desktop
* Linux
* Mac OS X
* Maya
* McAfee AV
* Office
* OpenOffice
* Oracle
* Partition Magic
* Perl Interpreter (original)
* PHP Interpreter
* Python Interpreter (original)
* Photoshop
* PowerDVD
* Quake
* Ruby Interpreter (original)
* Skype
* SQL Server
* Starcraft
* Symbian OS
* Visual Studio
* VMware
* Warcraft
* Winamp
* Windows
* Windows Media Player
* Winzip

Chris on July 21, 2008 8:50 AM

emst.cpp:141: error: no matching function for call to ‘boost::filtered_graphCGAL::Delaunay_triangulation_2CGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid , Is_finite_and_mstCGAL::Delaunay_triangulation_2CGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid , std::setCGAL::detail::EdgeCGAL::Delaunay_triangulation_2CGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid , std::pairCGAL::CGALi::CC_iteratorCGAL::Compact_containerCGAL::TdsfbCGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid , CGAL::Default_allocator, false, int , std::lessCGAL::detail::EdgeCGAL::Delaunay_triangulation_2CGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid , std::pairCGAL::CGALi::CC_iteratorCGAL::Compact_containerCGAL::TdsfbCGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid , CGAL::Default_allocator, false, int , std::allocatorCGAL::detail::EdgeCGAL::Delaunay_triangulation_2CGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid , std::pairCGAL::CGALi::CC_iteratorCGAL::Compact_containerCGAL::TdsfbCGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid , CGAL::Default_allocator, false, int , Is_finiteCGAL::Delaunay_triangulation_2CGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tds2CGAL::TvbCGAL::Filtered_kernelCGAL::Simple_cartesiandouble , CGAL::Tdsvbvoid , CGAL::Tdsfbvoid ::filtered_graph(Triangulation, IsFiniteFilter, MSTFilter)’

C++ fiend on July 26, 2008 10:53 AM

It is clear what he is saying; business managers need to give C++ programmers more time to fiddle around with code without producing results.

Josh on September 3, 2008 9:00 AM

c++ is very nice!!!

yan on October 11, 2008 8:39 AM

test

asdf on November 5, 2008 6:03 AM

Flon's Dictum: There is not now, nor will there ever be, a language in which it is the least bit difficult to write bad code.

Bill Drissel on December 1, 2008 8:24 AM

i have an problem in programming(C++).
i think u can solve it. i want to print a file whose name is aa.prn with the help of programming .
(by using laser printer).It means that sir if run the program then automatic output is printed using laser printer
i think u can under stand above.

surinder kumar on December 5, 2008 11:44 AM

OMG - Jeff wrote about C++ - but I thought he admitted he doesn't know C or C++. how the hell do you write a blog entry about something you have never used? This is just amazing.

Go, Jeff, go.

Tim on December 27, 2008 10:49 AM

c++ is so hard to understand>>>>>

Anonymous on August 9, 2009 12:11 PM

I think some people still use C++ for commercial development as its harder to reverse engineer than the newer languages (Java, C#, Python) which really matters to some people.

I recently benchmarked some protocol decoding (proprietary protocol) in Python, Java and C++. C++ was 13x faster than Java (based on the implementation, C would be similar). And C++ was 150x faster than Pure python. Considering how much time my server applications spends decoding 'messages', these performance numbers cannot be ignore.

Note: I'm not an expert Java developer, I had experts tune the Java test case.

Jason on February 6, 2010 9:52 PM

When a programming language don't help you to solve a problem, then it isn't appropiate to solve it.
When a programming language confuses you in solving a problem, then it is not the best choice.
Now, when the programming language is just a tool, and you don't need to worry about the language itself, and only with the problem that you are trying to solve, then this programming language is the best choice that you can do.

For example, in high level applications, how many times I forgot to put an "" in ATL WIN32 API variables, and it give me a lot of problems that made me wast a lot of time and money. Now, it's normal to forgot this, we are humans, and humans forget things. Then, C++ doesn't help me with any warnings (W4) or anything to solve this problem.

C++, in my opnion, isn't the best human friendly language to solve high level problems. There is languages that do this in a better way.

Alisson on February 6, 2010 9:52 PM

I have found very little need for C++, however, I have found the need for low level languages like C or assembler from time to time as well as higher level languages like Ruby or Java. C++ just seems to fall in the middle when I personally have not needed to develop anything. Perhaps we need to look at this a little differently:

1) There will be programmers who need to know the inner workings of the machine and be proficient with bit-twiddling. These programmers will write the core of the OS, applications, and back end processing and data storage as well as complex, speed optimized routines.
2) There will be programmers who need to understand more of the business and functional processes then express these as code to implement them.

Very rarely will these two cross. Who would want them to? Do you really think that the programmers designing the internal workings of an RDBMS would really do well talking to the accountants about the char of accounts? Would you really expect someone with 90% of the knowledge of an accountant to be able to use binary math or read hex?

Perhaps the message here is to use the right tool for the job, not only the right language, but also the right programmer.

The truly great programmers will understand how all of the logic gates work and how various methods of memory allocation will affect performance. These people are very important.

However, others will fully understand the business domain, and often they will be best served by a language that insulates them from the reality of how it all happens. Luckily, they will speak enough tech to communicate with the low level programmers to handle things when they need to.

Looking at this from the game perspective: There are those who write the 3d rendering engine, but there are also others that write story lines, do artwork, and record audio. The jobs are all important, but different.

Grant Johnson on February 6, 2010 9:52 PM

It is not just that one should select the right tool for the job, one must also choose from tools that one knows how to use effectively and eschew jobs that require tools for which he eschews training.

It is an absolute truth that C and C++ require the programmer to handle his own memory management. A well trained programmer not only is capable of this, but uses this to his advantage.

The poster's comment regarding the "age of abundance" is only a partial truth at best. There are plenty of programs which continue to be resource hogs. The ability to micro-manage those resources can be the difference between a usable interface/program and a nuisance application. Bill Gates once said something along the lines of "640KB is more memory than anyone will ever need," so apparently this is not the first age of abundance.

In fact for the last 20 years we have been in an age of abundance with processors, memory and cost improving by factors of around two annually. Yet, most do not have a computer ready for the newest MS operating system, Vista. In fact many computers purchased just in the last year are not Vista capable and those that are, are so minimally ready that I expect kernel thrashing (sic)*.

And what programmar that has written a Java routine that ran for 13 minutes crunching a solution wouldn't be excited to have the same functionality in C++ with a 1 minute running time. Java is often useful for a rapid prototype but then a C++ solution can provide optimized results.

We have projects that run for days, even months in the programming industry. Speed is important. Will always be important. No matter how much memory we have we seem to be able to fill it. I remember when 20MB drives were considered large. In 10 years I expect most of us to have 2TB or more at our disposal. We will use it all.

There can be no age of abundance until we prove P==NP. And this can't happen until we have quantum computers. Even then we will have even larger problems to solve.

C++ is a great tool. I like it better than C. I often use it and interface with existing C programs. At times I prefer it to Java but when I want platform freedom and a GUI, I trust Java. Even with Java it's important to understand memory concepts. GC is no assurance that memory will be used optimally. Occassionaly one must let go of the object and sometimes one has to call gc() directly.

* Kernel thrashing is, of course, literally impossible (by definition kernels remain in memory). My point is that the Vista OS requires enormous amounts of RAM by today's "abundant" standards.

Don Yessick on February 6, 2010 9:52 PM

I write code as a hobby, really. Simulations. Started with VB in Excel and then as my models got larger, moved (back) to FORTRAN and compiled basic. About 5 years ago, a colleague shamed me into learning C++. Took a while for it to become the first tool I turned to, but now that I'm reasonably comfortable (and less unproductive than I used to be), I enjoy the flexibility it offers and the neat things it lets you do. It's just a really neat language.

Simon Rodan on February 6, 2010 9:52 PM

I think C++, being such a general-purpose language and one which makes very few assumptions at the language level, is a language which has great appeal to those who take it seriously. It is riddled with problems, but there's a tremendous difference which is probably one of the reasons it has die-hard enthusiasts like myself.

When we run into a language barrier in many other languages which causes systemic problems in the code your team produces, there's little we can do about it but work around it. As an example, there is no really elegant solution to deal with resource cleanup in Java and people often neglect to cleanup resources properly in the finally block. In C++, there are plenty of solutions available that people have built on top of the language (ways to implement RAII) since these kinds of things are not language-level problems in C++: while the language doesn't always provide solutions, it doesn't restrict solutions either.

This kind of freedom is probably one of the greatest appeals of C++ just from a pure language standpoint without considering other factors like efficiency. It has also lead to a lot of exploration and experimentation which has caused truly elegant and superior solutions to bubble up, yet those solutions are often awkward when it comes to implementation because they are built on top of such a general-purpose language with no specific accommodations for such solutions.

This kind of freedom is also the language's downfall. Too many self-proclaimed gurus tend to get creative and devise solutions to problems which have already been solved, and their solutions are often inferior to those which have been accepted and reviewed. Consider how many people have implemented their own reference-counted smart pointer in C++ without considering polymorphism, capturing on-site deletion, and the need for weak references. If C++ is going to move forward, more developers need to focus on the solutions that have worked and why they have worked rather than abusing the freedom that the language provides to roll their own solutions when superior solutions already exist. When it comes to C++, there's much more to learn than just the language itself; the freedom requires that we carefully study how it can be used effectively since there are too many ways to use it ineffectively. The language also needs to evolve with these new discoveries and trends which it fortunately appears to be doing with C++0x.

Stinky472 on June 24, 2010 1:24 AM

C++ was created to manage increasing complexity. We're in the millions of lines of code these days. I haven't reached that point in my own software. Use it as needed.

me.yahoo.com/a/oA6qkEQHl9_5LOfvxL7q1jIr6CrYnL4- on July 12, 2010 1:56 AM

It's refreshing to see Jeff get the crap kicked out of him in the comments.

Though it is interesting for me, someone who likes C and Python, to see people defending C++ with the same things that make C great, and yet nobody seems to really be mentioning C itself. Hmm...

For all you C++ fanatics, by the way, Google for "C++ FQA".

Adam Marchetti on July 12, 2010 1:18 PM

«Back

The comments to this entry are closed.