r/cpp • u/tartaruga232 MSVC user, r/cpp_modules • Apr 26 '26
Code Examples From an App Using C++ Modules
https://abuehl.github.io/2026/04/26/code-examples-from-an-app-using-modules.htmlThis demonstrates usage of our recommendations for using modules:
- Prefer small modules
- Only use partitions if you really must
- Avoid using internal partitions
The intention is to show some real code for context of discussions about using C++ modules.
My goal is not to sell modules. If you prefer not using modules: Use header files. There are good reasons to continue using them.
For me, C++ source code is an asset. The intrinsic value of code using modules is higher (lower entropy), as modules are a higher abstraction, compared to header files, which are basically just the pasting of C++ code into translation units (I've done that for ~36 years now).
Using C++ modules comes at a cost though. Understanding modules requires a certain level of understanding, which isn't needed when using the simple model and tradition of header files.
View all comments
Show parent comment
0
u/Zero_Owl Apr 27 '26
I do use
using namespacea lot and it works great for me. In fact it is the only sane way of writing C++ code where you work with a properly designed namespace structure. And if it is designed properly the usage pattern is not different from C# which is pretty robust and convenient.There is no inherent problem with C++ regarding the namespaces, it is libraries that are at fault. Look at this code, for example:
And tell me in good faith that you would not use
using namespacewith that code. Now to std. Beforeimport stdusing namespace std;was usable. With some moderate caution, in cpp files but it was usable. It solved some headaches, created some. But withimport stdit became totally unusable and that's why std module is a bad example. It provides no alternative to the meager isolation we had w/o adding anything but compile times.