Remix.run Logo
petters 3 hours ago

> C++ doesn't take longer to compile if you don't abuse templates.

Surprisingly, this is not true. I've written a C++ file only to realize at the end that I did not use any C++ features. Renaming the file to .c halved the compilation time.

levodelellis 3 hours ago | parent | next [-]

I don't believe you, I measured compile times in c compilers and my own. If you provide more information I'd be more likely to believe you

levodelellis 2 hours ago | parent | prev [-]

In fact, I don't believe you so much that I'm willing to say you're full of shit. No compiler capable of both C++ and C will be twice as fast renaming the file to C

jsheard 2 hours ago | parent [-]

I agree it shouldn't really matter if there's no C++ features in play, but I suppose third party headers could bite you if they use #ifdef __cplusplus to guard optional C++ extensions on top of their basic C interface. In that case the compiler could be dealing with dramatically more complex code when you build in C++ mode.

uecker an hour ago | parent [-]

Maybe it is similar for the same compiler (but one should check, I suspect C could still be faster), but then there are much more C compilers. For example, TCC is a lot faster than GCC.

levodelellis 38 minutes ago | parent [-]

tcc is 8x faster, twice as fast isn't doing it justice.

As for the header thing, that'd could potentially be true if the compile time was something like 450ms -> 220ms, but why bother saying it when you're only saving a few hundred milliseconds