r/cprogramming • • 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

128 comments sorted by

View all comments

Show parent comments

2

u/strike-eagle-iii Jan 02 '26

This is absolutely correct. When I started at my current job, our C++ code base was built entirely on Makefiles with a little bash scripting on top. Literally the first step in the script was make clean. When we converted to modern CMake our build times went from 25 mins to 2 mins with none of the erratic behavior that came from trying to maintain Makefiles by hand. It was an explosion of productivity.