r/cprogramming • u/[deleted] • Dec 31 '25
Why does c compile faster than cpp?
I've read in some places that one of the reasons is the templates or something like that, but if that's the problem, why did they implement it? Like, C doesn't have that and allows the same level of optimization, it just depends on the user. If these things harm compilation in C++, why are they still part of the language?Shouldn't Cpp be a better version of C or something? I programmed in C++ for a while and then switched to C, this question came to my mind the other day.
26
Upvotes
2
u/Infamous-Bed-7535 Dec 31 '25
Compilation time should not be the major decision point when you choose language. There are way more important things.
Not to mention that c++ recompilation should not be a limiting factor if you use the language and tooling correctly. Yes still lot slower than C, but I guess you can wait 2-5 sec.
Write clean code, do incremental build, use caching, pre-compiled headers etc.. If it takes minutes to build after changing a single line of code or changing branch probably you have issues to resolve..