3 ms·
> C or C++ code bases get really brittle over time as developers forget what is actually going on This is very true. And one of the culprits is a lack of modul
by humanrebar 12y ago
> C or C++ code bases get really brittle over time as developers forget what is actually going on
This is very true. And one of the culprits is a lack of modules, an shortcoming that Rust avoids. A module system for C++ is grossly overdue, and I'm not holding my breath that one will be forthcoming.
- AnimalMuppet 12y agoWhat's your definition of a "module" that is not a class, not an object file, not a .so, and not a namespace? I'm not trying to be argumentative. I've seen this "C++ doesn't have modules" claim before, and I'm trying to get my mind around it.
- sinistersnare 12y agoC++ does not have modules. When people say modules they mean how the files compile, and the current way is #include directives which literally copy-pastes the contents of that file into the includer file. This is horribly horrible for compile times, and has been reviled for basically ever. Here read this: http://clang.llvm.org/docs/Modules.html http://clang.llvm.org/docs/Modules.html
- aidenn0 12y agoRight now the way you use a module in C++ is to tell the compiler to dump a subset of its source-code from that module into each file that uses it. Then you tell the linker to link in the objects from that module later. This is a pretty ridiculous and highly inefficient way of doing things (Facebook improved compile times by crafting a server just to do the preprocessing for you).
- humanrebar 12y agoPart of the reason that "modules" aren't in C++ yet is that there isn't a precise definition of what modules are or what they should be. That being said, C++ doesn't have even the bare minimum of what would be considered a module system according to any definition. With a lot of hand waving, one should be able to more or less write: import std::vector; ...and have the compiler (not the preprocessor!) find the relevant declarations and definitions for std::vector. Probably also important are additional restrictions to give more control over when and how preprocessor macros affect client code.