3 ms·
> Don't forget the differences in compilation model; C/C++'s compilation units are much smaller Not everyone compiles C++ the same way. I prefer header-only l
by civility 9y ago
> Don't forget the differences in compilation model; C/C++'s compilation units are much smaller
Not everyone compiles C++ the same way. I prefer header-only libraries and a single compilation unit. Counting lines of code with "gcc -E" to get the headers, I just compiled 20,000 lines of C++ from scratch in .6 seconds with gcc and .4 seconds with clang. I don't have a comparable project in Rust.
- pcwalton 9y agoHow much code did the preprocessor strip out?
- civility 9y agoNo idea, maybe a lot from the system headers. However, it was 20,000 lines of code that survived the preprocessor, 11,000 of which were inline or template from the project itself.
- comex 9y ago- A large fraction of compiler time is spent on code generation; how many of those lines did the compiler actually generate code for? (i.e. not unused functions or uninstantiated templates) (And in the case of uninstantiated templates, a C++ compiler doesn't even need to type check them…) - Did you have optimizations enabled?
- civility 9y ago> how many of those lines did the compiler actually generate code for? Not many. How many lines would a comparable Rust program have to instantiate? (should be the same) All I was trying to do was make an apples to apples comparison by discrediting the implication that the clang++ and g++ compilers are only faster because people use separate compilation units. I think it's fair to compare Rust and C++ this way, and if Rust is slower to compile, then it's fair to ask why. > Did you have optimizations enabled? Yes, -O3. Also -Wall -Wextra and -fwrapv if you're interested.