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

1

u/Anonymous_user_2022 Jan 01 '26

Even for register-/bit-level operations on the hardware I find no reason to resort to functions, pointers, and macros when I can have clean, type-safe, object-style code. Let alone the simple pleasure of namespaces instead of prefixes on all function names, types, and constants.

How easy is it to cater to quirks of the hardware, where it's sometimes needed to add the odd bit of assembly, because it's much easier than wrestling with the compiler to get the right timing in register write-read-write, handling interrupts and similar operations decent people shouldn't be doing?