Re:How to speed up the Rust compiler in 2018: NLL edition
by pjmlp on Tuesday November 06, 2018 @02:17PM
(#18394057)
You can get reasonably fast compile times in C++ with a mix of incremental compilation, incremental linking, binary libraries and if using clang or VC++, experimental modules support.
Still slower than compiling Ada, Delphi, Eiffel, D code, though.
Heavily templated C++ code is notoriously slow to compile so it's no surprise that heavily genericized Rust code doesn't fare much better.
On top of that Rust builds one crate at a time basically, it's not like C where you typically have plenty of smaller compilation units that are black-boxes to one-another. C++ has the same compilation model but as mentioned above templates need to be resolved completely at compile-time so all templated code ends up in headers and therefore in copy/pasted by the processor every compilation unit it's used in.
And then after all that in Rust you have the borrow checker which probably ads a non-negligible runtime overhead.
I agree that it's an interesting evolution as far as programming languages are concerned. I consider that Rust is overall superior to C but at the same time in the seventies nobody could have run a Rust compiler on anything more than a Hello World. Meanwhile I've just compiled (with optims) an auto-generated C file of about 20k lines almost instantly on my 2018 computer.