...

/

Need for Modules

Need for Modules

Understand the need for modules in C++ programming.

Modules are one of the four big features of C++20: concepts, modules, ranges, and coroutines. Modules promise a lot: shorter compile times, macro isolation, abolishing header files, and avoiding ugly workarounds. Before I present the advantages of modules, I want to step back and explain their benefits.

Why do we need modules?

Let me start with a simple executable. For obvious reasons, I create a “Hello World” program.

Making an executable main out of the program main.cpp with GCC increases its size by factor 226226.

#include <iostream>

int main() {
    std::cout << "Hello World" << '\n';
}
A simple hello world program

The numbers 7575 ...