News for hackers. Stuff that matters.
Re:The Rust compiler isn't slow; we are by flohofwoe on Wednesday June 17, 2020 @08:19AM (#23550477)
I had the same experience going from C++ back to C. I was surprised how fast my C code compiled, and how small the resulting executables were, even though I already tried to avoid the worst offenders in my C++ code.

The problem isn't that C compilers are "fast" or C++ compilers are "slow". C++ compilers are very fast, but typical C++ projects just throw way too much work at the compiler (by having too much implementation code in headers, while C headers are typically only declarations).

The underlying problem is that C++ makes it easy (and even encourages through bad practices in the stdlib) to add complexity and hide it under "fancy" interfaces, which indirectly leads to code that's slow to compile and results in a bloated compiler output.

It's possible to create C++ projects which compile just as fast, and result in just as small binary code as C projects (basically "embedded C++", but this means giving up most high-level features that C++ added on top of C (such as most of the C++ stdlib).

In short: C makes it hard to add accidental complexity under the hood, while C++ makes it easy. Add a cargo-style dependency manager to the mix, and the "accidental complexity" problem grows exponentially.

Re:The Rust compiler isn't slow; we are by JoeAltmaier on Wednesday June 17, 2020 @08:23AM (#23550507)
Agreed. Especially the stdlib part. In embedded environments I start by removing that. Pretty much cures the bloat issues.