Classy move: C++ 20 wins final approval in ISO technical ballot, formal publication expected by end of year

'Best approximation of C++ ideals so far,' says Stroustrup - but is it too big and complex?

C++ 20, the latest version of the venerable object-oriented programming language, has been unanimously endorsed in ISO's final technical approval ballot.

It awaits a "final round of editorial work," following which it will be formally published, expected to be "towards the end of 2020."

A major new version of C++ comes every three years, named after the year, so C++ 20 is the successor to C++ 17. C++ 20 is a big release, bigger than its predecessors. There are four key new features often called the “big four.” These are:

  1. Modules. Source code that gets compiled once and then reused as a binary file. They are a faster alternative to header files, isolate the code more, and will improve compile times.

    Bjarne Stroustrup, creator of C++, spoke about C++ 20 a year ago at Cppcon in Aurora, Colorado, remarking that the language had reached the human equivalent of middle age. He singled out modules as one of the two most significant features in C++ 20, because they “should improve our compile times by 5 to 10 times” – but only if developers use them to clean up their code.

  2. Another big feature, and the second one which Stroustrup highlighted, is called Concepts. “A concept is a compile-time predicate,” he explained in 2016. “For example, if a template takes a type argument, we can specify that an argument, T, can be an iterator, Iterator<T>, a random access iterator, Random_access_iterator<T>, or maybe a number, Number<T> … Concepts enable overloading and eliminate the need for a lot of ad-hoc metaprogramming.”

  3. Ranges library. Dependent on Concepts, Ranges abstract collections.
  4. Coroutines, functions that “can suspend execution to be resumed later,” used for asynchronous programming.

    There are many other new features, including the “spaceship operator” <=> which does a three-way comparison and returns less, equal or more.

Contracts, a feature once slated for C++ 20, has been moved out of this release and into a study group, as they were not ready.

C++ is an evolving language. Stroustrup said that “C++ 23 will complete C++ 20,” adding standard modules, library support for coroutines, Executors (a key feature for parallelism) and plenty more.

Is C++ becoming too large and complex?

It is an intimidating language, but the effect of the new features should be to simplify C++ programming. In his Cppcon talk, Stroustrup said that C++ 20 is “the best approximation of C++ ideals so far”, and that C++ 23 will be better still.

Stroustrup resisted efforts to describe the language in terms of the new features added with each major release. “The language is not a layer cake,” he said.

He has advocated starting with the “simple and elegant features” and not worrying about parts of the language which may be there only for backward compatibility, which he said was critically important. The burden of backward compatibility falls on implementers rather than users, and that is how it should be, said Stroustrup, because there are many thousands of users but only a few implementers.

verity stob portrait

Bjarne Again: Hallelujah for C++


One of the goals, according to Stroustrup, is to reduce the need for template metaprogramming. “Template metaprogramming was a wildly successful C++ 98 feature … the fact that it was so heavily used, even though it was so ugly and difficult, is proof of its utility. We have to make it easier to do the things that were done in template metaprogramming,” he said. Features including Constexpr functions, in C++ 11, and Concepts in C++ 20, help with this, he said.

Good C++ code should be easy to understand, according to Stroustrup. “One of the measures of good code is that I can understand it,” he said.

The major C++ compilers do not yet implement everything in C++ 20. A list of what is implemented in Clang is here, and GCC here (no Modules support yet). The latest Visual C++ supports some C++ 20 features when used with flags such as /experimental:module and /std:c++latest. A table of compiler conformance status is here.

C++ ranks as the fifth most popular programming language in the Redmonk language rankings, and is – if anything – creeping up. In 2012, when these rankings were first calculated, it took seventh place. Despite the attention devoted to more recent languages such as Rust and Go, C++ is here to stay. ®

Similar topics

Narrower topics

Other stories you might like

  • The wild world of non-C operating systems
    You can't fool me, young man. It's C all the way down!

    Believe it or not, not everything is based on C. There are current, shipping, commercial OSes written before C was invented, and now others in both newer and older languages that don't involve C at any level or layer.

    Computer hardware is technology yet very few people can design their own processor, or build a graphics card. But software is a form of culture. Open source is created by volunteers, even if they end up getting paid jobs doing it. Even rejecting open source is a choice: paying for Windows or macOS instead reflects a preference.

    This is especially visible when it comes to text editors, and even more so about programming languages. People get passionate about this stuff. So statements such as "C isn't a programming language any more" can be upsetting. Most people live and work in the cultures that are Unix and Windows and if they are all you've ever known, or know best, then it's easy to think they are the whole world.

    Continue reading
  • Any fool can write a language: It takes compilers to save the world
    The language wars were fun, but they're done

    Opinion Here's a recipe for happiness. Don't get overexcited by the latest "C is not a language" kerfuffle.

    Proper coders have known since its inception that C is as much a glorified library of assembler macros as anything else. Don't sweat it. That business with operating systems being infected by their old C genes, crippling all the new cool Rusts and Swifts? So what? If your code is limited by its OS interactions, you should probably go write a kernel.

    There is one place, and one place only, where you should invest your emotional and intellectual  energies. Compilers. They saved the world once, and they're about to do it again.

    Continue reading
  • Microsoft proposes type syntax for JavaScript
    Long overdue innovation or an affront to all that developers hold dear?

    Type-fans rejoice! Plans (or a proposal, at least) are afoot to pop some type-checking into the infamously dynamically typed JavaScript.

    The proposal planned from Microsoft and others, including devs from the Igalia Coding Experience program and Bloomberg, is all about adding "types as comments" to the language.

    The theory is that it would become possible to have a syntax for types that could be used by tools that need those hooks (such as Microsoft's own TypeScript) and ignored by those that do not.

    Continue reading

Biting the hand that feeds IT © 1998–2022