Advantages of Modules

Get familiar with the advantages of the modules.

Here are the advantages of modules in a concise form:

  • Modules are imported only once and are literally for free.
  • It makes no difference in which order you import a module.
  • Duplicate symbols with modules are very unlikely.
  • Modules enable you to express the logical structure of your code. You can explicitly specify names that should be exported or not. Additionally, you can bundle a few modules into a bigger module and provide them to your customer as a logical package.
  • Thanks to modules, there is no need to separate your source code into an interface and an implementation part.

🔑 The long history

Modules in C++ may be older than you think. My short historic detour should give an idea of how long it takes to get something so valuable into the C++ standard.

In 2004, Daveed Vandevoorde wrote proposal N1736.pdf, which described for the first time the idea of modules. It took until 2012 to get a dedicated Study Group (SG2, Modules). In 2017, Clang 5.0 and MSVC 19.1 provided the first implementations. One year later, the Modules TS (technical specification) was finalized. Around the same time, Google proposed the so-called ATOM (Another Take On Modules) proposal (P0947) for modules. In 2019, the Modules TS and the ATOM proposal were merged into the C++20 committee draft (N4842).


Get hands-on with 1200+ tech skills courses.