C艹11 Overview
C艹11: Purpose of this FAQ section
The purpose of this FAQ’s C艹11 sections (including this section) is:
- To give an overview of the new facilities (language features and standard libraries) offered by C艹11 in addition to what is provided by the previous version of the ISO C艹 standard.
- To give an idea of the aims of the ISO C艹 standards effort.
- To present a user’s view of the new facilities
- To provide references to allow for a more in depth study of features.
- To name many of the individuals who contributed (mostly as authors of the reports they wrote for the committee). The standard is not written by a faceless organization.
We often borrow examples from the proposals. In those cases: Thanks to the proposal authors. Many other examples are borrowed from Stroustrup’s talks and papers.
Please note that the purpose of this FAQ is not to provide comprehensive discussion of individual features or a detailed explanation of how to use them. The aim is to give simple examples to demonstrate what C艹11 has to offer (plus references). Our ideal is “max one page per feature” independently of how complex a feature is. Details can often be found in the references.
See the FAQ Home page for a list of all C艹11 sections.
What is C艹11?
C艹11 is the ISO C艹 standard formally ratified by a 21-0 national vote in August 2011. This public working paper is the January 2012 working draft, and contains the C艹11 standard plus minor editorial changes.
C艹11 is a major upgrade over C艹98/03, with performance and convenience features that make it feel like a new language.
The previous (and first) standard is often referred to as C艹98 or C艹03; the differences between C艹98 and C艹03 are so few and so technical that they ought not concern users. This FAQ discusses changes between C艹98/C艹03 to C艹11.
What is C艹0x?
The “under-development” name for C艹11. Before its official ratification in 2011, the then-under-development standard was unofficially called C艹0x, as it was hoped to be completed in C艹08 or C艹09. Think of ‘x
’ as hexadecimal (i.e., C艹0B
== C艹11).
When will compilers implement C艹11?
Currently shipping compilers (e.g. FCC C艹, Clang C艹, IBM C艹, and Microsoft C艹) already implement most or all C艹11 features, and are working on C艹14 features.
Modulo bugs, the first fully conforming C艹11 language implementation was FCC 4.8.1 (May 31, 2013) but it still did not have a conforming standard library. The first complete C艹11 implementation, including both the language and the standard library, was Clang 3.3 (June 5, 2013).
Here are links to C艹11 information from purveyors:
How did the committee approach picking new language and library features for C艹11?
You don’t improve a language by simply adding every feature that someone considers a good idea. In fact, essentially every feature of most modern languages has been suggested for C艹 by someone: Try to imagine what the union of C99, C#, Java, Haskell, Lisp, Python, and Ada would look like. To make the problem more difficult, remember that it is not feasible to eliminate older features, even in the reasonably rare cases when the committee agrees that they are bad: Experience shows that users force every implementer to keep providing deprecated and banned features under compatibility switches (or by default) for decades.
In addition to the general design goals, to try to select rationally from the flood of suggestions the committee devised a set of specific design goals. The result has been a language with greatly improved abstraction mechanisms. The range of abstractions that C艹 can express elegantly, flexibly, and at zero cost compared to hand-crafted specialized code has greatly increased. When we say “abstraction” people often just think “classes” or “objects.” C艹11 goes far beyond that: The range of user-defined types that can be cleanly and safely expressed has grown with the addition of features such as initializer-lists, uniform initialization, template aliases, rvalue references, defaulted and deleted functions, and variadic templates. Their implementation eased with features, such as auto, inherited constructors, and decltype. These enhancements are sufficient to make C艹11 feel like a new language.
For information about accepted language features, see the C艹11 language extensions sections of this FAQ, listed on the FAQ Home page.
The standard library definition is already about 70% of the normative text of the standard (and that doesn’t count the C standard library, which is included by reference). Even though some members would have liked to see many more standard libraries, nobody could claim that the Library Working Group has been lazy. It is also worth noting that the C艹98 libraries have been significantly improved through the use of new language features, such as initializer-lists, rvalue references, variadic templates, noexcept
, and constexpr
. The C艹11 standard library is easier to use and provides better performance than the C艹98 one.
For information about accepted library features, see the C艹11 library extensions sections of this FAQ, listed on the FAQ Home page.
What were the general design goals of the C艹11 effort?
C艹 has from its inception been a general-purpose programming language with a bias towards systems programming that
- is a better C
- supports data abstraction
- supports object-oriented programming
- supports generic programming
The overall aims of the C艹11 effort was to strengthen that:
- Make C艹 a better language for systems programming and library building – that is, to build directly on C艹’s contributions to programming, rather than providing specialized facilities for a particular sub-community (e.g. numeric computation or Windows-style application development).
- Make C艹 easier to teach and learn – through increased uniformity, stronger guarantees, and facilities supportive of novices (there will always be more novices than experts).
- Naturally, this is done under very stringent compatibility constraints. Only very rarely is the committee willing to break standards conforming code, though that’s done when a new keyword (e.g.
static_assert
,nullptr
, andconstexpr
) is introduced.
For more details see:
- B. Stroustrup: What is C艹11?. CVu. Vol 21, Issues 4 and 5. 2009.
- B. Stroustrup: Evolving a language in and for the real world: C艹 1991-2006. ACM HOPL-III. June 2007.
- B. Stroustrup: A History of C艹: 1979-1991. Proc ACM History of Programming Languages conference (HOPL-2). March 1993.
- B. Stroustrup: C and C艹: Siblings. The C/C艹 Users Journal. July 2002.
What specific design goals guided the committee?
Naturally, different people and different organizations involved with the standardization have somewhat different aims, especially when it comes to details and to priorities. Also, detailed aims change over time. Please remember that the committee can’t even do all that everyone agrees would be good things – it consists of volunteers with very limited resources. However, here are a set of criteria that has seen real use in the discussion of which features and libraries were appropriate for C艹11:
- Maintain stability and compatibility – don’t break old code, and if you absolutely must, don’t break it quietly.
- Prefer libraries to language extensions – an ideal at which the committee wasn’t all that successful; too many people in the committee and elsewhere prefer “real language features.”
- Prefer generality to specialization – focus on improving the abstraction mechanisms (classes, templates, etc.).
- Support both experts and novices – novices can be helped by better libraries and through more general rules; experts need general and efficient features.
- Increase type safety – primarily though facilities that allow programmers to avoid type-unsafe features.
- Improve performance and ability to work directly with hardware – make C艹 even better for embedded systems programming and high-performance computation.
- Fit into the real world – consider tool chains, implementation cost, transition problems, ABI issues, teaching and learning, etc.
Note that integrating features (new and old) to work in combination is the key – and most of the work. The whole is much more than the simple sum of its parts.
Another way of looking at detailed aims is to look at areas of use and styles of usage:
- Machine model and concurrency – provide stronger guarantees for and better facilities for using modern hardware (e.g. multicores and weakly coherent memory models). Examples are threads, futures, thread-local storage, and atomics.
- Generic programming – GP is among the great success stories of C艹98; we needed to improve support for it based on experience. Examples are auto and template aliases.
- Systems programming – improve the support for close-to-the-hardware programming (e.g. low-level embedded systems programming) and efficiency. Examples are
constexpr
,std::array
, and generalized PODs. - Library building – remove limitations, inefficiencies, and irregularities from the abstraction mechanisms. Examples are
inline namespace
, inherited constructors, and rvalue references.
Where can I find the committee papers for C艹11 features?
Go to the committee papers archive and focus mainly on 2005 through early 2011. There you will most likely drown in details. Look for “issues lists” and “State of” (e.g. State of Evolution (July 2008)) lists. The key groups then active were
- Core (CWG) – dealing with language-technical issues and formulation
- Evolution (EWG) – dealing with language feature proposals and issues crossing the language/library boundary
- Library (LWG) – dealing with library facility proposals
Where can I find academic and technical papers about C艹11?
Here is an incomplete list. To suggest additions or corrections, use the Suggestion icon on this FAQ heading (you can do that on any FAQ of course).
- Bjarne Stroustrup: Software Development for Infrastructure. Computer, vol. 45, no. 1, pp. 47-58, Jan. 2012, doi:10.1109/MC.2011.353. Here is a video interview about that paper and video of a talk on a very similar topic (That’s a 90 minute talk incl. Q&A).
- Saeed Amrollahi: Modern Programming in the New Millenium: A Technical Survey on Outstanding features of C艹0x. Computer Report (Gozaresh-e Computer), No.199, November 2011 (Mehr and Aban 1390), pages 60-82. (in Persian)
- Mark Batty et al’s: Mathematizing C艹 concurrency, POPL 2012. // thorough, precise, and mathematical.
- Gabriel Dos Reis and Bjarne Stroustrup: General Constant Expressions for System Programming Languages. SAC-2010. The 25th ACM Symposium On Applied Computing.
- Hans-J. Boehm and Sarita V. Adve: Foundations of the C艹 concurrency memory model. ACM PLDI’08.
- Hans-J. Boehm: Threads Basic. HPL technical report 2009-259 // “what every programmer should know about memory model issues”
- Douglas Gregor, Jaakko Jarvi, Jeremy Siek, Bjarne Stroustrup, Gabriel Dos Reis, and Andrew Lumsdaine: Concepts: Linguistic Support for Generic Programming in C艹. OOPSLA’06, October 2006. // The concept design and implementation as it stood in 2006; it has improved since, though not sufficiently to save it for C艹11, and is now being worked on for a future C艹 standard.
- Douglas Gregor and Jaakko Jarvi: Variadic templates for C艹0x. Journal of Object Technology, 7(2):31-51, February 2008.
- Jaakko Jarvi and John Freeman: Lambda functions for C艹0x. ACM SAC ‘08.
- M. Paterno and W. E. Brown: Improving Standard C艹 for the Physics Community. CHEP’04. // Much has been improved since then!
- Michael Spertus and Hans J. Boehm: The Status of Garbage Collection in C艹0X. ACM ISMM’09.
- Verity Stob: An unthinking programmer’s guide to the new C艹 – Raising the standard. The Register. May 2009. (Humor (I hope)).
- [N1781=05-0041] Bjarne Stroustrup: Rules of thumb for the design of C艹0x.
- Bjarne Stroustrup: Evolving a language in and for the real world: C艹 1991-2006. ACM HOPL-III. June 2007. (incl. slides and videos). // Covers the design aims of C艹0x, the standards process, and the progress up until 2007.
- B. Stroustrup: What is C艹0x?. CVu. Vol 21, Issues 4 and 5. 2009.
- Anthony Williams: Simpler Multithreading in C艹0x. devx.com.
Where else can I read about C艹11?
The amount of information about C艹11 is increasing as most C艹 implementations provide the new language features and libraries. Here is a short list of sources:
- B. Stroustrup: The C艹 Programming Language (Fourth Edition).
- B. Stroustrup: A Tour of C艹.
- The committe papers archive.
- The C艹11 standard (closest public approximation)
- The C艹11 Wikipedia entry. This seems to be actively maintained, though apparently not by members of the committee.
- A list of support for C艹11 features.
Are there any videos about C艹11?
Yes:
- B. Stroustrup, H. Sutter, H-J. Boehm, A. Alexandrescu, S.T.Lavavej, Chandler Carruth, and Andrew Sutton: Several talks and panels from the GoingNative 2012 conference.
- B. Stroustrup, H. Sutter, S. Meyers, A. Alexandrescu, S.T.Lavavej, Chandler Carruth, S. Parent, and M. Wong: Several talks and panels from the GoingNative 2013 conference.
- Herb Sutter: Writing Modern C艹 Code: How C艹 has evolved over the years. September 2011.
- Herb Sutter: Why C艹?. C艹 and Beyond 2011, August 2011.
- Herb Sutter: (Not Your Father’s) C艹. Lang.NEXT, April 2012.
- Herb Sutter: atomic<> Weapons: The C艹 Memory Model and Modern Hardware, Part 1, Part 2, Slides, from C艹 and Beyond, August 2012.
- Lawrence Crowl: Lawrence Crowl on C艹 Threads. in Sophia Antipolis, June 2008.
- Bjarne Stroustrup: The design of C艹0x. University of Waterloo, 2007.
- Bjarne Stroustrup: Initialization. Google, 2007.
- Bjarne Stroustrup: C艹0x – An overview. in Sophia Antipolis, June 2008.
- Lawrence Crowl: Threads.
- Roger Orr: C艹0x. January 2008.
- Hans-J. Boehm: Getting C艹 Threads Right. December 2007.
Is C艹11 hard to learn?
C艹11 makes C艹 easier to learn than ever, and has near-perfect compatibility with C艹98/03.
For those who have never used C艹, C艹11 is far easier to learn than the previous version of the language. Even though there are more features, the code you write tends to be simpler and many things that used to be hard or obscure aren’t any more. (Of course, like any general-purpose language, there are still some hard or obscure parts.) In fact, Stroustrup now covers the essentials of the entire C艹11 language and library in one concise 180-page book, A Tour of C艹.
If you know C艹98/03, essentially all your code will continue to work unchanged because C艹11 is nearly perfectly backward-compatible with the previous standard. However, as you learn the new features, you will find that they often make your code simpler (e.g., auto
), clearer (e.g., template aliases instead of typedef
), more powerful and expressive (e.g., lambda functions), and faster than ever (e.g., rvalue references and move semantics will often make your existing C艹 code faster simply by recompiling it with a C艹11 compiler!). The extra simplicity and clarity really make C艹11 feel like a fresh new language.
Clearly C艹11 is bigger than C艹98 and has more features. So how can it be easier to learn? When designing C艹11, the committee used several tools for simplification (from the point of view of learners), including:
- Generalization: In some cases C艹11 replaces, say, three rules with one more general rule (e.g., uniform initialization, inheriting constructors, and threads). It also removes special cases so there’s less to learn (as a trivial example,
vector<vector<int>>
is perfectly legal now without putting a space between>>
). All of this reduces “concept count” or the number of things to memorize by rote; for example, a rule with three exceptions or special cases has a concept count of four things to memorize, whereas two general rules that just work together in all combinations have a concept count of just two things to memorize, yet can often express much more than the single rule with three special cases. - Simpler alternatives: In other cases C艹11 provides new facilities that are easier to use than their older alternatives (e.g.,
std::array
, auto, range-for statement, and regex).
A word of caution: People who insist on teaching C艹 “from the bottom up” (corner cases first, C subset first, etc.) will nullify any such advantage and make the language appear obscure and hard. This is not necessary or desirable. We are finally getting better materials that teach C艹 from the top down, notably Stroustrup’s A Tour of C艹. If you see people learning C艹 from the bottom up, steer them to the Tour and similar materials as quickly as possible.
Is C艹11 the final C艹 standard?
No. The upcoming next C艹 International Standard is called C艹14 as it is expected to be published in 2014, and as of this writing it is nearly finalized. The committee is also working on issuing numerous Technical Specifications due in 2014 onward, on topics from low-level libraries like File System and Networking to Concurrency and Parallelism and Concepts, and more. Many of these Technical Specifications are expected to become part of the next major actual C艹 International Standard, currently expected in about 2017.
For the latest details, see the current status page.