Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11: a new language?

Tags:

c++

c++11

Recently I started reading (just a bit) the current draft for the future C++11 standard.

There are lots of new features, some of them already available via Boost Libs. Of course, I'm pretty happy with this new standard and I'd like to play with all the new features as soon as possibile.

Anyway, speaking about this draft with some friends, long-time C++ devs, some worries emerged. So, I ask you (to answer them):

1) The language itself

This update is huge, maybe too huge for a single standard update. Huge for the compiler vendors (even if most of them already started implementing some features) but also for the end-users.

In particular, a friend of mine told me "this is a sort of new language".

  • Can we consider it a brand new language after this update?
  • Do you plan to switch to the new standard or keep up with the "old" standard(s)?

2) Knowledge of the language

  • How the learning curve will be impacted by the new standard?
  • Teaching the language will be more difficult?
  • Some features, while pretty awesome, seem a bit too "academic" to me (as definition I mean). Am I wrong?
  • Mastering all these new additions could be a nightmare, couldn't it?
like image 503
Gian Paolo Ghilardi Avatar asked May 07 '09 12:05

Gian Paolo Ghilardi


People also ask

What is C11 language?

C11 is the informal name for ISO/IEC 9899:2011, the current standard for the C language that was ratified by ISO in December 2011. C11 standardizes many features that have already been available in common contemporary implementations, and defines a memory model that better suits multithreading.

Should I use C11?

It is best to use C11 as that is the current standard. C99 and C11 both contained various "language bug fixes" and introduced new, useful features.

What is the difference between C99 and C11?

C11 looked to address the issues of C99 and to more closely match the C++ standard, C++11. It changes some C99 features required to optional. Some of the features include variable length arrays and complex numbers. This makes it easier for compiler vendors to meet C11's required function set.


2 Answers

In short, no, we can't consider this a new language. It's the same language, new features. But instead of being bolted on by using the Boost libs, they're now going to be standard inclusions if you're using a compiler that supports the 0x standard.

One doesn't have to use the new standard while using a compiler that supports the new standard. One will have to learn and use the new standard if certain constraints exist on the software being developed, however, but that's a constraint with any software endeavor. I think that the new features that the 0x standard brings will make doing certain things easier and less error prone, so it's to one's advantage to learn what the new features are, and how they will improve their design strategy for future work. One will also have to learn it so that when working on software developed with it, they will understand what's going on and not make large boo-boos.

As to whether I will "switch to the new standard", if that means that I will learn the new standard and use it where applicable and where it increases my productivity, then yes, I certainly plan to switch. However, if this means that I will limit myself to only working with the new features of the 0x standard, then no, since much of my work involves code written before the standard and it would be a colossal undertaking to redesign everything to use the new features. Not only that, but it may introduce new bugs and performance issues that I'm not aware of without experience.

Learning C++ has always been one of the more challenging journeys a programmer can undertake. Adding new features to the language will not change the difficulty of learning its syntax and how to use it effectively, but the approach will change. People will still learn about pointers and how they work, but they'll also learn about smart pointers and how they're managed. In some cases, people will learn things differently than before. For example, people will still need to learn how to initialize things, but now they'll learn about Uniform Initialization and Initializer Lists as primary ways to do things. In some cases, perhaps understanding things will be easier with the addition of the new for syntax for ranges or the auto return type in a function declaration. I think that overall, C++ will become easier to learn and use while at the same time becoming easier to teach.

Mastering a language is a long-term goal, it can not be done over night. It's silly to think that one can have mastery over something as complex as C++ quickly. It takes practice, experience and debugging code to really hammer something in. Academically learning is one thing, but putting to use that knowledge is an entire different monster. I think that if one already has mastery of the C++ language, the new concepts will not pose too much of a burden, but a new comer may have an advantage in that they won't bother learning some of the more obsolete ways of doing things.

like image 131
Mike Caron Avatar answered Sep 18 '22 15:09

Mike Caron


1) The language itself

As far as I'm aware, there are really no breaking changes between C++'03 and C++'0x. The only one I can think of here relates to using auto as a storage class specifier, but since it had no semantic meaning I don't see that being an issue.

There are a lot of other academic fixes to the standard which are very necssary, for example better descriptions for the layout of member data. Finally, with multi-core/cpu architectures becoming the norm, fixing the memory model was a must.

2) Knowledge of the language

Personally, I feel that for 99.9% of C++ developers the newer language is going to be easier to use. I'm specifically thinking of features such as auto, lambda's and constexpr. These features really should make using the language more enjoyable.

At a more advanced level, you have other features such as variadic templates etc that help the more advanced users.

But there's nothing new here, I'm still surprised at the amount of everyday C++ developers that haven't used (or even heard of) the STL.

From a personal perspective, the only feature I'm a bit concerned about in the new standard is that of concepts. As it is such a large change, the same problems that occurred with templates (ie. completely broken implementations) is a real danger.

Update post FDIS going out for voting:

As it happens, 'concepts' was dropped for C++ 0x and will be taken up again for C++ 1x. In the end there are some changes other than auto which could break your code, but in practise they'll probably be pretty rare. The key differences can be found in Appendix C.2 of the FDIS (pdf).

like image 25
Richard Corden Avatar answered Sep 20 '22 15:09

Richard Corden