Hacker News new | ask | show | jobs
by amluto 490 days ago
> compile times

C++, especially “modern” C++, can have truly horrible compile times. The lack of a usable module system makes it worse.

Variadic templates helped some. Fold expressions will help some. I expect concepts and if constexpr and such to help some: relying on SFINAE never did the compiler any favors.

But, in general, C++ template programming is quite nasty for compile times.

1 comments

Yes as I said "And some of them depend on whether you are comparing to C or C++: compared to C, Rust has many disadvantages, but C++ has many of the same disadvantages, and often is worse."

C++ compile times can be as bad as Rust's or worse. It does depend on how you structure things and how much you use templates. You don't need to have 10 layers of "zero cost abstraction" around everything. But that is the "proper" way to use it and what is now taught, so there is a lot of it out there and the standard library does it pervasively.

Variadic templates don't fix much compared to just writing straight line code or doing a tiny bit more work at runtime using stdarg.h.

Variadic templates help quite a lot compared to what older libraries did or even still do to approximate them. Check out boost::variant’s shenanigans — I recall a single-line file that includes <boost/variant.hpp> and doesn’t even instantiate the variant template taking several seconds to compile.