3 ms·
I guess it depends on what you're used to. Each time I switch from C to C++, compile times take some adjusting. If you're not careful about how you organise yo
by pg314 10y ago
I guess it depends on what you're used to. Each time I switch from C to C++, compile times take some adjusting.
If you're not careful about how you organise your C++ code (be careful what you put in headers, don't go crazy with templates), compiling can get really slow, even for relatively small projects.
Just #include <iostream> and the compiler needs to process 37,799(!) lines and more than a MB of data:
echo '#include <iostream>' | g++ -E -x c++ - | wc
37799 104779 1280834
To contrast in C:
echo '#include <stdio.h>' | gcc -E -x c - | wc
456 1638 20880
Comparing the compile times of PostgreSQL (C, minutes on an old laptop) and MySQL (C++, 30+ minutes) is also instructive.
Maybe when modules are finally introduced, things will improve.
- majewsky 10y agoThe numbers seem to depend heavily on your environment, by the way: $ uname -m x86_64 $ source /etc/os-release && echo $NAME Arch Linux $ echo '#include <iostream>' | g++ -E -x c++ - | wc 27336 59448 643240
- pg314 10y agoSure. Mine was macOS Sierra. If your <stdio> is comparable to mine, that's still about 30 times more bytes that the compiler sees for C++ compared to C.