On Rust compilation times

77 points theMachine0094

How does one compare the compilation time of one language with that of another, and do it fairly? I guess one can write the same toy program in two languages and compare them. But for a toy program compilation times are tiny and don’t matter. If you write a large project, you end up having dependencies and you don’t really know what you’re measuring. Forgive my ignorance on the subject.

The closest thing I have is a comparison between two of my projects, one in C++ and the other in Rust. The C++ project is roughly 2x larger (LOC) than the Rust project. I am using vcpkg to manage C++ dependencies. Both projects end up pulling over 100 dependencies. The C++ project takes forever to compile. I usually switch to another task and come back to it after a while. Rust project’s compilation is crazy fast by comparison. I don’t switch to another task. I haven’t measured the exact times because the projects are different enough that those numbers won’t mean much. But just based on feel alone, Rust compilation times are almost nothing compared to C++. I don’t understand all the complaints and memes about slow compilation. Why don’t such memes exist for C++? Over the years I got used to waiting for C++ projects to compile so Rust compilation seems really fast to me. What am I missing here?