Feeds

back to article 'Major' C++ revision receives standards blessing

Changes to the standard behind of one of the world's most popular programming languages have been approved by standards chiefs. The next version of C++ has been approved during a unanimous ballot by the International Organization for Standardization (ISO). Official publication of what will now be called C++11 is expected by the …

COMMENTS

This topic is closed for new posts.
WTF?

So ,,,

"C++ was created by Bjarne Stroustrup as a general purpose programming language that was both powerful and simpler to use than C, thanks to the inclusion of object orientation."

So, what went wrong? Because that's exactly what C++ isn't.

This announcement isn't clarifying anything.

6
5
Anonymous Coward

C++ delivers

Why the compulsion to fling mud at something you clearly have no experience with? It's all about context - you're not going to use C++ in place of web scripts, macros, or similar small projects. But for large projects, C++ delivers exactly what it promises - power and simplicity. For those who work with C++, this is an extraordinarily big step forward (and does indeed simplify many things). Why exactly should it matter if that doesn't bring any clarity to you?

7
3
Silver badge

Competing demands, that's all

C++'s complexity is a result of the desire to create a language that can automate everything that more extreme languages supply while making it all optional and without taking one step away from the language having as close as possible to no runtime.

It's a grand unification, even while the world shows a preference for niche languages.

0
1
Bronze badge

C++ doesn't deliver

I have had the experience of working with a fellow who, after working with C++ since its inception, couldn't write an iterator without bugs. That makes me very paranoid about C++, the claims made about it, and the people using it. This is a language that overloads left bit shift! And for no rational reason that I can fathom. C++ started out as an abuse of the C preprocessor, and of course I'd like to see it cleaned up. Maybe this will be a step in the right direction, and maybe it won't.

2
1
Anonymous Coward

Another "I once knew someone who..." experience

@Brian Miller: "I have had the experience of working with a fellow who, after working with C++ since its inception, couldn't write an iterator without bugs."

Fine - but my comment to Craiggy applies to you as well - why the compulsion to fling mud at something you clearly have no experience with? You're quoting second-hand information that doesn't sound very credible in the first place. Writing an iterator isn't a common-place thing to do in the first place - the STL provides an excellent range of container classes already fully equipped with iterators. But I've actually written a few in the course of developing object wrappers for low-level APIs, and can't say I had *any* difficulty whatsoever.

Operator overloading can, of course, be a disaster when misused. The same is true of almost any language feature - but even goto can be a good thing *in the right context*. Overloaded operators, when used appropriately, are fantastic, and the code is very readable. This was the reason for overloading the bit-shift operators for i/o - it's succinct, visual, and very readable. Do you want to complain about using the addition operator for concatenating strings too? Only people who actually *use* C++ are in a position to make that kind of judgement. For everyone else, C++ just seems to be a popular target to hurl insults at.

0
0
WTF?

OS X?

OS X programming is usually done using Objective-C, which was an early rival to C++.

As for Stroustrup's contention that C++ was "simpler" than C because it included support for object orientation: I can only assume he was heavily intoxicated at the time.

12
2
FAIL

IOKit Fail

All the stuff that stultifying Objective-C uses to get anything at all done on the machine is written in C++. It's called IOKit, and IMHO is a shining example of "good C++" - elegant, simple and ridiculously efficient.

2
0
E 2

Am I the first to post a comment?

Can I haz a cookie?

0
14
Unhappy

Sigh...

..when do the school holidays finish again?

0
0
Anonymous Coward

More please!

Nice to hear that the decision was unanimous - there seems to be so little accord generally, it makes a nice change. Love the improvements too - can't wait for the (full) implementation.

4
0
Bronze badge

Now that they have a "standard"...

Will anyone conform to it? Or will we we be balkanized by the likes of those who want to make it "sharper"?

Life goes on.

3
0
Silver badge

Programmers needed

Is it me, or do all the new kids learn Java, Python, and some new stuff I can't remember right now?

0
0
Silver badge
Thumb Up

Teachers with no programming experience...

... love Java, because it can be taught from a book. Academia is stuffed with Java programmers, even for tasks that you shouldn't touch with an interpreted, garbage-collected runtime. I laughed the first time someone said "Real-time Java". Now, the joke has worn off.

C++11 (or C++0x as it was known) is a great addition to the standard. The inimitable Ms Stob has this guide : http://www.theregister.co.uk/2009/05/07/verity_stob_cplusplus/

There's a lot in there to address the teachability of C++, particularly the reuse of the rare "auto" keyword to now mean: "look, you're the compiler, you know what type this function returns, just make this variable that type, and don't make me type something insane with three levels of angle-brackets in it"

2
0

OS X

It's true that user-space programming for OS X is typically done using Objective-C.

Have a look into the kernel and you'll find lots of C++, as well as C (BSD origins, after all). The driver model presumes C++.

3
0
Anonymous Coward

Finally!

All I can say it's about time to get it past the standardisation committees! C++11 has many sorely-needed smaller and bigger improvements that help with everyday programming productivity. If you compare Java in 1998 and Java today, they are on a totally different level.

I know C++ is "old-fashioned" these days. But Java has become old-fashioned, too, by the same metric of current coolness. And (dare I say it) for Python the same fall from grace is just around the corner... life goes on and the codebases keep growing - it's a far more workable solution to modernize and refresh the language every now and get many of the benefits of using the new cool language of the moment. Steal and adapt the good ideas from other languages as much as you like.

0
0
Ru
Silver badge
Paris Hilton

Why wasn't it C++0B?

C++ isn't old fashioned so much as complex and specialist and as a result doesn't spend a whole lot of time in the limelight. I'm writing a lot of fairly complex image processing code these days, and no other mainstream language comes close to the usefulness of C++, and I'd be doing future maintainers a grevious disservice by using some sort of crazy moon language with a similar feature set (say, D).

Thirty years from now, I expect it to have the same status that COBOL does now; widely disliked, most practitioners dead, yet still used all over the place. I look forward to some lucrative consultancy.

0
0
Happy

@ratfox

This brings a whole generation of old-school programmers back into relevance. Those of use who learnt C++ properly can use it for anything the interpreter-kiddies can do in their languages. And produce code that runs like the wind on multi-core machines.

I'm just waiting for some smart ass to come up with a Java->C++11 precompiler.

1
1
Facepalm

Herb Sutter

is higly tied with Microsoft interests. What could go wrong having private interests tinkering with C++?

I'll keep using C (there's already decents multi-core programming APIs) rather than the unfortunate "++" sequel.

2
4
Ru
Silver badge
Meh

A language with commercial supporters? Say it aint so!

A quick look at the TIOBE popular language list:

Java: Oracle. PHP: Zend. C#, VB: Microsoft. Objective-C: Apple.

That's 42% of the scores right there. Turns out that big software companies have an interest in the languages they develop in! Who'd have thought? Also, using C outside of serious stuff like OS kernels, drivers (woe betide anyone who encourages C++ drivers. Seriously, what are thinking, Apple?) and embedded systems stuff is all about pain and frustration. But you know, some people like that.

3
1

I respectly

disagree. C is a breeze compared to 'modern' alternatives like Java, C# and C++.

But don't worry it's just me.

4
0
Silver badge

woohoo!

list<pair<string, string>> words = {

{ "Woo", "hoo" },

{ "About bloody", " time" },

};

for (auto& i : words)

{

cout << i.first << i.second << endl;

}

0
0
Facepalm

@Tom 38

A nice demonstration of just how unreadable even the simplest C++ program can be.

For me, the only thing about C++ that was better than C was the // comment format. Since that was added to the C standard in 1999, I'll stick with C.

I remember reading Stroustrup's book back in 1992. I kept finding things which made me think "OK, but why would you want to do such a thing?", and "What happened to the KISS* principle?". But I suppose there are fashions in everything.

*Keep It Simple, Stupid.

6
3

@nyelvmark

So what part of it do you not understand? I really don't see which part of it could be construed as unclear when trying to get a general understanding of what it does.

It's true that there are complex topics in C++, but a fair few of those are just down to backwards-compatibility with C (I really wish they could just get over their hump and start C++ afresh with this standard coming through, oh well) and the others are solved by giving up and using a third-party library like any of Boost.

If you don't have an understanding of C++ you quite probably won't know the reasons things were done a specific way, that doesn't mean there aren't good reasons.

1
3
Silver badge

You are so right, we should use C for everything

Or maybe assembler?

Look, if you don't use C++, and decided in the early 90s that you would never want to use C++, why comment on the evolution of a language that you have already prejudged?

It's just like the Android fanboy who reads a story about a new iphone, and immediately posts the first comment "zzz, who cares".

Personally, I almost had to go have a 5 finger shuffle when I read that we would now have an 'auto' type, for which the compiler will work out the appropriate type, or a simpler way to iterate through STL collections, or many many of the other fantastic things that C++0x will have available. In fact....

fapfapfap

4
0

Excuse me, but ...

... any language can be used to write ugly. I say this as someone who has written Perl for over 15 years and who is on a project to modernize some 20-year-old Oracle databases.

2
0
Silver badge

yeah!

don't you speak curly bracket? How could that be any clearer?

Maybe by adding some more words....

0
0

Re: Excuse me, but...

"... any language can be used to write ugly."

Sadly, very true, but some languages make it much harder to be elegant then others.

0
0
Meh

an 'auto' type, for which the compiler will work out the appropriate type

So how is that a good thing? Firstly, it may introduce bugs where the type that the compiler chooses isn't the type that the programmer intended; secondly, it reduces (as C++ so often does) the readability of the code for other programmers, who will need to to look elsewhere for the meaning of the code they're reading. And it adds nothing to the performance of the program, since data types are a high-level abstraction which mean nothing at the object-code level.

Have you ever considered what would happen if you got run over by a bus when your code is 90% complete? Another programmer would either need to pick up your code and run with it, or scrap most of it and start afresh.

If I was forced to use this 'auto' type, I would find it necessary to add a comment wherever I used it, indicating which type I expected the compiler to choose, which is actually more work than explicitly declaring the type in the first place.

Oh, I suppose you could use it for polymorphism, where the same code does different things depending on the data type encountered (as, for example, with overloading), but that way lies madness...

1
0

@nyelvmark

"I remember reading Stroustrup's book back in 1992. I kept finding things which made me think "OK, but why would you want to do such a thing?", and "What happened to the KISS* principle?".

Bjarne was carefully following his veresoin of the KISS principle. Tht's the one where KISS stands for "Keep It Stupid, Silly".

1
0
Silver badge
WTF?

See, this is where your lack of C++ knowledge lets you down

C++ is strongly typed. The compiler cannot 'choose' a type for you, each rvalue has a specific type, and hence using auto simply eliminates some keyboard action.

The standard case will be for turning something like this:

std::vector<std::map<std::string,std::pair<std::string, std::string>>> the_list;

for (std::vector<std::map<std::string,std::pair<std::string, std::string>>>::const_iterator i = the_list.begin(), e = the_list.end(); i != e; ++i) ;

into something like this:

std::vector<std::map<std::string,std::pair<std::string, std::string>>> the_list;

for (auto& i: the_list) ;

Does that reduce the readability? Really? (Ok, so a list of maps of string -> (string, string) is not a typical data structure, but I've seen far worse in stl-hell)

There can be no chance of implicit type conversion either - in fact, I can think of several times over the years where using an auto type would have prevented some incorrect implicit type conversions.

You may not use C++, but I do on a daily basis, and C++0x is pure win.

PS: Do you not have standard 'hit by bus' policies at your work? All our stuff has to survive a weekend of several fatalities...

2
0

@nyelvmark

In what way would the below C++98 be clearer than Tom 38's version? What does the added verbosity gain?

list<pair<string, string> > words;

words.push_back(pair("Woo", "Hoo"));

words.push_back(pair("About bloody", "Time"));

list<pair<string, string> >::const_iterator i = words.begin();

while (i != words.end())

{

cout << i.first << i.second << endl;

++i; // mustn't forget this

}

I thought Tom38's post made some everyday C++11 advantages clear: the old way required a loop condition test and manual iterator increment (chance for errors) as well as a redundant declaration of the iterator type (more work to change to use a different container if needed, as well as the general fiddliness and verbosity of STL iterators).

What important information is the auto keyword hiding? Now that the features are in the standard, these should become common C++ idioms that any programmer worth anything will recognise and read fluently.

This is just the kind of syntactic sugar that raises the abstraction level slightly and makes programs more readable, as well as making the initial and subsequent programmers touching the code more productive (get rid of a common class of bugs, make reading the code faster and make refactoring easier - what's not to like?).

0
0
This topic is closed for new posts.