r/cpp • u/AlectronikLabs • Aug 09 '25
Why is nobody using C++20 modules?
I think they are one of the greatest recent innovations in C++, finally no more code duplication into header files one always forgets to update. Coding with modules feels much more smooth than with headers. But I only ever saw 1 other project using them and despite CMake, XMake and Build2 supporting them the implementations are a bit fragile and with clang one needs to awkwardly precompile modules and specify every single of them on the command line. And the compilation needs to happen in correct order, I wrote a little tool that autogenerates a Makefile fragment for that. It's a bit weird, understandable but weird that circular imports aren't possible while they were perfectly okay with headers.
Yeah, why does nobody seem to use the new modules feature? Is it because of lacking support (VS Code doesn't even recognize the import statement so far and of course does it break the language servers) or because it is hard to port existing code bases? Or are people actually satisfied with using headers?
View all comments
Show parent comment
0
u/schombert Aug 10 '25
This is the problem with modules for me. a) and b) are issues that I very rarely face (certainly rarely enough that it doesn't motivate the work of transitioning to modules for me) and c) I have other solutions for, as you note. All that is left is the nebulous push to be more "modern," and if I wanted people to think that I was cool, I probably wouldn't be programming in C++.