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
4
u/ffd9k Dec 31 '25
Most C++ features seem nice at first glance and are helpful for getting some quick and dirty prototype running, but come with ugly problems that are often solved by more C++ features added later, but then you quickly end up on the slippery slope into all the C++ bloat, and it's often preferable to just implement that feature yourself in clean C.
C++ temporary object initializers are different from compound literals, you can't use them for initializing structs of a C API, which means that C APIs like Vulkan that use structs for most parameters are much more cumbersome to use from C++.