3 ms·
> That said, avoiding libraries (especially avoiding templates and just using void*-like stuff) does keep binaries/libs smaller, but I'll gladly make the comput
by mihai_ionic 13y ago
> That said, avoiding libraries (especially avoiding templates and just using void*-like stuff) does keep binaries/libs smaller, but I'll gladly make the computer work slightly harder considering that the result is the same speed (C++ is often faster than C, in practice).
This should not be an issue with modern C++ compilers. If two template instantiations generate the same or similar code, they will be merged and useless code is removed by dead code elimination.
> The downside I care about is compilation speed. Simple C projects compile/link faster than modern C++ ones, even though the code for the same functionality is far more brittle, unsafe, and opaque
At the same time, a lot of potential for optimization is lost by barricading everything between translation units and/or behind opaque pointers.
While yes, LTO is supposed to help there, all those memory accesses make it infinitely harder for the compiler to prove trivial properties about the data flow. See also this recent presentation by someone who has a lot more experience than me with writing compiler backends: http://www.youtube.com/watch?v=eR34r7HOU14 http://www.youtube.com/watch?v=eR34r7HOU14
- saurik 13y ago> This should not be an issue with modern C++ compilers. If two template instantiations generate the same or similar code, they will be merged and useless code is removed by dead code elimination. FWIW, MSVC does this, maybe Intel's as well, but other toolchains do not.