3 ms·
Includes mixed with #ifdef leaks state across module borders and the whole C preprocessor feels like a dirty hack. What a header actually does depends on compi
by std_throwaway 8y ago
Includes mixed with #ifdef leaks state across module borders and the whole C preprocessor feels like a dirty hack.
What a header actually does depends on compiler flags, #defines from other files and then the order in which you include things as one header file might define something that changes the behavior of another header file. The compiler loses state in between C++-files and caching precompiled header files was still a joke the last time I've checked.
That leads to the problem that every single C++ file needs to include a few hundred thousand lines of nested headers and compilation takes forever. Add in some templates and you get a lot duplicated code in the object files that needs to be weeded out by the linker. Sometimes it's even suggested to put all your classes into one single big C++ file and only compile that in order to get your compilation time down.
Having proper modules would do so much good!
- mort96 8y agoCompiling Chromium, the biggest C++ project I know, takes on the order of 8 hours with a somewhat old but quite powerful server. Linking Chromium on my laptop, with 8GB of RAM, required me to increase my swap space from 8GB to 16GB. Going away from C's linker and header file-model, which really doesn't work well for C++, to something based on a proper module system, would be amazing.
- std_throwaway 8y agoWhat I'd like to have is someone to devise a plan on how to seamlessly progress from C++ to a language with a wholly new and cleaned up syntax. A way to slowly break out of the shell given by current backward compatibility. But at the same time being able to seamlessly interact with the old C and C++ world. Maybe something like "unsafe" in Rust. Having modules in C++ smells like the connector we're missing in order to accomplish something like that.