3 ms·
I have a large C++ code base (mostly C++11), and I agree with this article. My code base is hilariously slow to compile, and the biggest single culprit is the
by amluto 8y ago
I have a large C++ code base (mostly C++11), and I agree with this article. My code base is hilariously slow to compile, and the biggest single culprit is the variant header. I sometimes wonder whether I should just remove all the users to save time.
To add insult to injury, std::variant is a rather bad approximation of a sum type. variant<int,int> is only partially functional, and you can’t disambiguate the two ints by name the way you could in, say, Rust.
I think that a lot of these problems stem from two systematic problems
1. The desire to avoid modifying the language. A good modern language should have sum types. Heck, the ranges paper explains how ranges fundamentally have the wrong semantics wrt const and that this can’t be fixed without changing the language. So fix the language, please!
2. The fact that even new libraries are specified to be header files. Surely there could be a variant module even if modules aren’t really for full deployment.
- modeless 8y agoUnfortunately modules don't solve the compile time problem, as demonstrated in the article, which matches my own experience. I was excited about modules until I tried them out and realized they don't help much in practice. I hate to sound like a broken record but I've been telling everyone I know to try https://zapcc.com https://zapcc.com. If you are on Linux then it is a real solution to long compile times, especially for incremental builds.
- jcelerier 8y ago> My code base is hilariously slow to compile, and the biggest single culprit is the variant header. yeah, <variant> is so slow that I wrote my own (domain-specific but could be repurposable) variant-like code generator. It keeps the same API but makes everything sooooooooooooo much faster to compile - especially the visitations with multiple arguments. (ugly fugly, full of dirty hacks, but it only had to run once or twice : https://github.com/OSSIA/libossia/blob/master/tools/gen_variant/gen_variant.cpp https://github.com/OSSIA/libossia/blob/master/tools/gen_vari...)