Paul Krill
Editor at Large

C++ 23 to introduce module support

news
Jun 2, 20222 mins

Starting with the standard library, modules promise to improve both compilation speed and how C++ developers organize code.

Hands access a keyboard while a monitor displays binary code.
Credit: M-A-U / Getty Images

C++ 23, the planned next version of the C++ programming language due to be finalized in 2023, is set to move forward with support for a standard library module and faster compilation.

The upgrade to the language is likely to include a standard library module, called std, and some support for coroutines, language designer Bjarne Stroustrup said. With the standard library module, “Hello World” becomes as follows:

import std:
int main()
{
   Std::cout<< "Hello, World!n";
}

This will compile 10 times faster than the old version using #include <iostream>, Stroustrup said.

Modules not only give improved compilation speed and better code hygiene, but also unify source organization of ordinary functions and templates, Stroustrup noted. The .h/.cpp distinction disappears and C++ source code is fundamentally simplified. “Eventually, modules will be the most significant improvement ever to the way we organize our code,” he said. 

C++ 23, which is being developed under the ISO (International Organization for Standardization), will have many minor improvements, some of which will not seem minor, Stroustrup said. He noted that it was never supposed to be a major upgrade of C++ the way C++ 11 and C++ 20 were. Rather, it was supposed to complete C++ 20 and hopefully ship a few significant features.

However, the pandemic forced a limit on ambitions. “It has been difficult to hold good design discussions virtually, and many people believe the lack of face-to-face contact has been a great handicap,” Stroustrup said. As a result, features such as pattern matching, contracts, and a general model for concurrency (executors) will have to wait until C++ 26.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author