An Interview With C++ Creator Bjarne Stroustrup
DevTool writes "Bjarne Stroustrup talks about the imminent C++0x standard and the forthcoming features it brings, the difficulties of standardizing programming languages in general, the calculated risks that the standards committee can afford to take with new features, and even his own New Year's resolutions."
Of course by this point it really should be called the imminent C++1x standard.
"I don't care about the Constitution!" --Bill O'Reilly, November 17, 2009
They should have added nullptr 20 years ago. It's always amusing to read about C++'s design for type safety when we've been forced to sling around magic '0' literals all this time because someone got their panties in a bunch over automatic casting of void*.
I am becoming gerund, destroyer of verbs.
It seems to me that most tasks that seem good for C++ would be better handled using a mix of an easier-to-program language (Ruby, Python, heck even lisp or smalltalk or anything else) with C extensions.
IMHO C++ seems not very good at very low-level programming; since with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading and rather convoluted implicit casting rules. In C you're using a pretty good tool for low-level programmings (especially with a dialect where you can sneak in a few assembly calls where you need to). In Ruby you're using a reasonably nice and efficient to develop in OO language. With the incredible ease of writing C extensions for Ruby, it's easy to use the best tool for each part of the job you're doing. The only compelling reason to use C++ I can think of is if some political policy forces you to use a single language for an entire project; and then I guess C++ not quite as clunky as java or c#.
( though I'm kinda repeating myself - a longer rant I made on slashdot about the pains of C++ years ago is here http://slashdot.org/comments.pl?sid=100202&cid=8540772 . An even more condemning annoyance about C++ is that thanks to so many convoluted tricks in the language, most people who claim C++ knowledge don't actually know it, as evidenced by the comments in that old thread )
XBMC
GitHub Source.
Stop trying to add more redundant features to C++... it is already getting progressively harder for C++ programmers to read each other's code and teach newbies what something means.
All this does is result in yet more more syntactic sugar to teach people in order to accomplish the same tasks they can already do with the older standards, and yet another round of relearning so you can tell what someone who learned a 'neat new trick' is doing. And of course you STILL need to teach the old methods to newbies so they can understand C++ code that they have to maintain.
Seriously.. this really does not help.
We could add more, it would be a trivial change.
There's no -1 for "I don't get it."
Not that I disagree with your feelings but QT is a major C++ magnet -- of course you could argue that QT is a language on its own, not really C++.
Don't judge a website by the stylesheet.
GAAH! MY PRINTER IS ON FIRE!!! PUT IT OUT! PUT IT OUT!
I always preferred this interview with Bjarne Stroustrup.
(Yes, I know it's not real, but...)
I don't know, I see a LOT of C++ job postings. Most desktop and server application (designed for sale) development is still done in C++, and it is pretty common in middleware.
See-plus-plus-zero-ex doesn't really roll off the tongue. How about something a bit easier? Super-C, C-flat, Cmega+ or something lame that people can actually say.
(Here's your queue to explain to me what the proper pronunciation is. AND the reason for picking such a weird name)
> Games developers, a few corporate app maintainers and...
Most Mozilla project applications including Firefox.. Pretty much all of KDE and some of GNOME. WebKit. Google Chrome. Opera. A good chunk of OpenOffice. Most Adobe applications. Most Microsoft desktop applications including Internet Explorer. CUPS. The Qt toolkit and pretty much everything that uses it. MySQL. Autodesk Maya. Winamp.
I wouldn't say a *few* corporate apps are written in C++, I'd say pretty much every major desktop app that's undergone a major re-write within the last two decades is probably C++.
My Other Computer Is A Data General Nova III.
I concur with your anecdotal evidence with my own observations and I share your opinions. But it seems like its moot compared to some of the hard data I've seen in the past.. It may be trending down, but it's not down yet.
I believe it is also a regional thing, C# seems to dominate the Mid-Western US with Java domination on the US coasts. With C++ being, well, elsewhere out of my ethnocentric regionalisms. Again, just my own personal anecdotal evidence.
A libertarian shat on my carpet once. Claimed the free market would sort it out. -Ford Prefect(8777)
Early C++ introduced void* and it was good. C adopted it.
Then C++ took away the automatic casting, I guess about the time C++ was first standardized. OK, now what is the point? The value of void* is gone. Now we write code with nasty casts. We can even hide the nasty casts in macros. Oh joy.
C remains fairly sane. There haven't been any serious fuckups since the trigraph disaster which no compiler enables by default. C99 is damn nice in fact.
Interviewer: Well, it's been a few years since you changed the
world of software design, how does it feel, looking back?
Stroustrup: Actually, I was thinking about those days, just before
you arrived. Do you remember? Everyone was writing 'C'
and, the trouble was, they were pretty damn good at it.
Universities got pretty good at teaching it, too. They were
turning out competent - I stress the word 'competent' -
graduates at a phenomenal rate. That's what caused the
problem.
Interviewer: Problem?
Stroustrup: Yes, problem. Remember when everyone wrote Cobol?
Interviewer: Of course, I did too
Stroustrup: Well, in the beginning, these guys were like demi-gods.
Their salaries were high, and they were treated like
royalty.
Interviewer: Those were the days, eh?
Stroustrup: Right. So what happened? IBM got sick of it, and
invested millions in training programmers, till they were a
dime a dozen.
Interviewer: That's why I got out. Salaries dropped within a year,
to the point where being a journalist actually paid better.
Stroustrup: Exactly. Well, the same happened with 'C' programmers.
Interviewer: I see, but what's the point?
Stroustrup: Well, one day, when I was sitting in my office, I
thought of this little scheme, which would redress the
balance a little. I thought 'I wonder what would happen, if
there were a language so complicated, so difficult to learn,
that nobody would ever be able to swamp the market with
programmers? Actually, I got some of the ideas from X10,
you know, X windows. That was such a bitch of a graphics
system, that it only just ran on those Sun 3/60 things.
They had all the ingredients for what I wanted. A really
ridiculously complex syntax, obscure functions, and
pseudo-OO structure. Even now, nobody writes raw X-windows
code. Motif is the only way to go if you want to retain
your sanity.
Interviewer: You're kidding...?
Stroustrup: Not a bit of it. In fact, there was another problem.
Unix was written in 'C', which meant that any 'C' programmer
could very easily become a systems programmer. Remember
what a mainframe systems programmer used to earn?
Interviewer: You bet I do, that's what I used to do.
Stroustrup: OK, so this new language had to divorce itself from
Unix, by hiding all the system calls that bound the two
together so nicely. This would enable guys who only knew
about DOS to earn a decent living too.
Interviewer: I don't believe you said that...
Stroustrup: Well, it's been long enough, now, and I believe most
people have figured out for themselves that C++ is a waste
of time but, I must say, it's taken them a lot longer than I
thought it would.
Interviewer: So how exactly did you do it?
Stroustrup: It was only supposed to be a joke, I never thought
people would take the book seriously. Anyone with half a
brain can see that object-oriented programming is
counter-intuitive, illogical and inefficient.
Interviewer: What?
Stroustrup: And as for 're-useable code' - when did you ever hear
of a company re-using its code?
Interviewer: Well, never, actually, but...
Stroustrup: There you are then. Mind you, a few tried, in the
early days. There was this Oregon company - Mentor
Graphics, I think they were called - really caught a cold
trying to rewrite everything in C++ in about '90 or '91. I
felt sorry for them really, but I thought people would learn
from their mistakes.
Interviewer: Obviously, they didn't?
Stroustrup: Not in the slightest. Trouble is, most companies
hush-up all their major blunders, and explaining a $30
million loss to the shareholders would have been difficult.
Give them their due, though, they made it work in the end.
Interviewer: They did? Well, there you are then, it proves O-O
works.
Stroustrup: Well, almost. The executable was so huge, it took
five minutes to load, on an HP works
There's still a market for low level C programmers, and for Java, C#, Perl, Python, VB, and just about everything else, but who uses C++ these days? Games developers, a few corporate app maintainers and... uh... hang on...
Not sure if you're being facetious or not here, but C++ is consistently in the top 3 languages (the others being C and Java) in terms of popularity and usage. It's well above PHP, C#, Perl, Python, VB, Obj-C, and so on. I realize that stats from Tiobe index, Sourceforge, Langpop and other sources are merely an educated guess as to what people are really using, but the fact that nearly all agree on these three languages as being the top contenders seems to add credibility to their accuracy. It certainly beats the opinion of some individuals who are biased toward their favorite (or least favorite) languages.
kept alive by beardy wierdies and a few caffeine soaked kids who'll burn out and end up writing SQL for banks in a couple of years
Hey wait a minute! I resemble that remark!
Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
The biggest beef I have with C++ is linking.
Linking to a library that was compiled in a different C++ compiler (or even a different version of the compiler you have) is somewhere between painful and downright impossible; this is because function name mangling was never standardized and the core libraries are often incompatible.
Couldn't they standardize this in C++? It would make life so much nicer for those who deal in binaries.
There's no -1 for "I don't get it."
According to Wikipedia, "C++0x" is pronounced "see plus plus oh ex". After three rounds of macro preprocessing, four expansions of template substitutions, and reversing five levels of dynamic cast operator overloads, the name is eventually compiled to something readable: C plus plus? Oh, my ex-programming language!.
Because it's still just C++. C++0x is just one particular version, like C++98 or C++03. Java 1.6.23 doesn't exactly roll off the tongue either.
Let's ask Bjarne the same question: List of C++ Applications
Chop off half of the software applications on that list, at random -- can you still use your computer now? How about the internet?
Entomologically speaking, the spider is not a bug, it's a feature.
The std::thread and std::async libraries should give you all the tools you need in a plaform-independent way. The popular compiler vendors seem to be eager for C++0x - once the standard is official, Visual Studio will do a patch, and I'm sure G++ will beat them to release. Many of the C++0x features are already there with the -std=gnu++0x option to G++, though I'm not sure if that includes the threading stuff.
Socialism: a lie told by totalitarians and believed by fools.
What is it about operator overloading that gets people all tied up in knots? An operator is just a function. It has a name, just like every other function. That name can be helpful or misleading, just like every other function. Operators are just functions. Really.
It's a long time before anyone starts to use nullptr.
If you ever ran Visual Studio 2010, you have used a product that uses nullptr in some parts of its source.
(while we're at it, it also has C++0x lambdas)
I never realized that the standard for C++ hadn't been updated in 13 years...
Actually, the last update was in 2003 - known, surprisingly, as C++03. It's what most C++ compilers these days implement. It was just comparatively minor, mostly bug fixing and clarifying ambiguous points etc. Though some new features sneaked in - e.g. it lets you write new int[10]() to dynamically allocate a default-initialized array.
That there is a code generator there is really an implementation detail. From programmer's point of view, signals and slots are really just a language extension, and could as well be implemented by the compiler directly.
It's a long time before anyone starts to use nullptr. NULL is still shorter to type and too entrenched in the documentation.
In which documentation? "The C++ Programming language" mentions it twice, and says it's a C thing which you should avoid -- just use 0. Which is what I do.
Of course you can still *call* it "the NULL pointer" when you talk about it.
It is ugly as hell but it is readable... why more sites do not have a printer friendly page is beyond me (or I missed the link)!
Oh yeah, be prepared to scroll down a lot to get to the meat.
Page 1/3:
http://webcache.googleusercontent.com/search?q=cache:http://www.codeguru.com/cpp/misc/article.php/c18357/An-Interview-with-C-Creator-Bjarne-Stroustrup.htm&hl=en&client=firefox-a&hs=5K7&rls=org.mozilla:en-US:official&strip=1
Page 2/3:
http://webcache.googleusercontent.com/search?q=cache:http://www.codeguru.com/cpp/misc/article.php/c18357__2/An-Interview-with-C-Creator-Bjarne-Stroustrup.htm&hl=en&client=firefox-a&hs=kN7&rls=org.mozilla:en-US:official&strip=1
Page 3/3:
http://webcache.googleusercontent.com/search?q=cache:http://www.codeguru.com/cpp/misc/article.php/c18357__3/An-Interview-with-C-Creator-Bjarne-Stroustrup.htm&hl=en&client=firefox-a&hs=kN7&rls=org.mozilla:en-US:official&strip=1
Now since I have posted a comment like a good /.er I can go RTFA.
Limited to your local desktop's CPU cores, written in C or C++? You probably want to look at OpenMP, probably combined with some compiler intrinsics for vector math. (Or you can use a third-party library which already does things like that.)
I'll note that, limiting yourself to your desktop's CPU cores cripples even the average web-targeted netbook. You'd be much better off delegating the number crunching to your GPGPUs. (Even my desktop's HD3200 integrated video chipset ought to be able to trounce my Phenom 9650 for a problem like that.)
Efficient use of parallel resources depends a great deal on the nature of the problem you want to solve. As the most demanding consumers of parallel resources push for even more capacity, more tools are developed. The more tools that get developed, the more complicated the problem is discovered to be.
There are efforts to take different approaches on the problem, primarily (from what I've seen) in developing alternate programming languages that try to neatly solve those problems that existing programming languages have difficulty with, but they tend to require thinking about problem solving from a vastly different perspective, and have their own systemic complexities and weaknesses.
In other words, in the area of parallel computation, programming is experiencing an even greater tower-of-Babel event than any other area of programming I'm aware of. This extends from libraries to language extensions, to languages and on through models of programming.
tasks(723) drafts(105) languages(484) examples(29106)
So, I am an unapologetic Qt freak.
It does everything pretty damn easily and extends your C++ compiler by using a MetaObjectCompiler (MOC pre-processor) and gives you most, not all, of what C++0xForever is promising. Platform independently.
Of you don't like Qt, then there is Boost. Both are just C++ libraries.
Slashdot's rate-of-post filter: Preventing you from posting too many great ideas at once.
The core Boost classes were written by guys on the C++0x committee - they were written with the intent of becoming part of the standard library eventually. It's nice to have commonly used libraries incorporated into the language standard, especially to standardize cross-platform interfaces to platform-dependent stuff like threads.
But some stuff like Lamba just gets better syntax sugar if you change the language instead of using a library. While I'm not all that happy with the new C++ lambda syntax (what's wrong with making lamba a keyword, guys? same for you C# guys?), is still way easier than the Boost lamba syntax.
And some stuff like move semantics are just an outright fix to the language. Vector will stop requiring that Foo be copyable - finally!
Socialism: a lie told by totalitarians and believed by fools.
And for a lot of C++ programmers, the word JAVA triggers the thought "Lego coder". It will change, no doubt.
I understand your point, but I would argue that a really good programmer that only knows a single language does not exist. I don't see how one can become a good programmer without a little intellectual curiosity which would drive them to experiment and learn other languages. I started out many moons ago with Assembler, Basic, Fortran and COBOL, tried LISP (didn't like it), moved on to Pascal and PL/I, then picked up C, followed by C++, tried Objc-C (didn't like it) then Java, Perl and later C#, Groovy, Javascript and various scripting languages. I'm now kicking the tires or Scala, Python, PHP, Go and Erlang. Not one of these languages is "unworthy" of me. Every one has it's merits and is interesting for their unique attributes (even the ones I didn't like).
C++ programmers who dismiss others with experience in these other languages are showing their ignorance , inflated ego, or probably both. If a C++ programmer makes statements like "Java scripters are not real programmers", chances are they aren't nearly as good a C++ programmer as they think they are.
Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
NULL is defined to be integer 0 in C++, so you have to do these workarounds when you use NULL, as well; indeed, one of the advantages of using 0 is that it serves as a bit of a reminder that you need to keep these workarounds in mind.
lamba is not a keyword for two reasons:
a) it mostly evokes elvish pastry (properly spelt lembas)
b) lambda (/\), the Greek letter, is very common in scientific code, and making it a keyword would be painful.
Many games use two languages (C++ for the core, and something like Lua for the game logic) and it works perfectly fine.
Dilbert RSS feed
C++0x is the draft name. If it is published by the ISO in 2011 then it will be C++11.
The reason nobody has ever wanted lambdas
Why do you speak for other people? I don't know a single experienced C++ developer who wasn't excited about lambdas. For one thing, they finally make STL algorithms actually usable, because you don't have to write insane amount of boilerplate.
For that matter, consider the fact that someone bothered enough to write Boost.Bind and Boost.Lambda, and that even more people used that. This alone shows that a lot of people wanted lambdas.
they're ugly, confusing, and difficult to maintain.
Ugly is subjective.
Confusing - every mainstream language today except Java has them. Heck, VB - VB of all things! - has them, and VB code monkeys don't find it confusing. Perhaps you should catch up with times?
Difficult to maintain - what, more difficult than hand-written functors with explicit state capture and all that entails? I highly doubt so.
The code is cleaner and better formatted using an actual function.
When comparing lambdas to functions, you miss the crucial point of lambdas, which is the fact that they can capture state - that's what makes them so useful. If you e.g. need a function object to pass to std::find_if, and you need to compare against a value of the local variable in that function object, it's trivial to do with lambda:
The above is concise (compared to the old way, anyway; Rubyists would probably chuckle), and perfectly clear in its intent.
On the other hand, you cannot use find_if that way with a plain function at all. You can do it with a handwritten class with overloaded operator(), but then you have to declare the field to save the state, and make sure you initialize it properly. What's worse is that it's tucked away from where it's actually used, so the call to find_if is that much less readable due to need to jump to the definition of the class.
I hope we are not using C++ anymore by 2098...
Rethinking email