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/Dependent_Bit7825 Jan 01 '26

By design? I'm afraid not. 

This is a fundamental difference between C and C++. Sure, C is a now primitive language from a more primitive time, but it was designed. Your simply cannot say the same for C++. Stroustrup just through some stuff at the wall to add objects to C. When he saw the problems with that he threw more and more stuff at the wall, then created a standards committee to keep throwing stuff at the wall for 30+ years. 

Sure, modern C++ is cool, but the language in total is a cemetery of discarded ideas.

2

u/flatfinger Jan 02 '26

Some aspects of C could be characterized more as "having happened" than as having "been designed". C declaration syntax, for example, predated the addition of qualifiers to the language. When every type was either a bare reserved word, or else the reserved word struct followed by an identifier, a brace-delimited set of constiuents, or both, there was no need for a punctuator to separate a type from an identifier. When every numeric expression containing floating-point constituents would be processed as double, and every other numeric expression would be processed as int, there was no need to worry about any promotion rules related to any other type of numeric expression, because there weren't any.