November 25, 2015 | Software Engineering | Volodymyr Korniichuk
The 2015 CppCon conference, which took place in September, witnessed a claim from the developers of Visual C++ compiler, that the next update (Visual Studio 2015 Update 1) of C++ compiler by Microsoft will feature module support – an experimental feature from the new (not yet adopted) C++ standard.
Some words to explain the importance of this innovation: the mechanism of using components in programs written in C++ dates back some 35 years ago. This mechanism is not a convenient one: if you want to create a library, you will have to create a header file and accompany it with the code or the compiled version of the library. It generates lots of problems:
the header file and library are separate files, which means that one of them may be lost, or they may accidentally become out of synch;
the header file is included in the code by the #include preprocessor directive, which, firstly, slows down the compilation, and, secondly, piles up the influence of everything which is written in the header files upon each other and upon the final code. It is not infrequent, that headers must be included in a specific order, or that some macros must be determined, for the code to compile correctly.
This means that C++ lacks the notions of assembly and package. Unlike C# or Python, where installing components is easy, adding a new library in C++ may have unexpected results. The module support in C++, which is being introduced now, aims at solving this problem by eliminating the #include preprocessor directive and treating the components as a unity, which consists of a code and metadata and can be easily added. As an eventual result, new components may be added to a project significantly faster, full-scale package managers will appear, and adding a library will require executing one line of code or several mouse clicks.
Below are the links to the proposed draft of the module standard and its realization in Visual C++ and Clang.