4 ms·
This post is really interesting. As a member of the rust-analyzer team, I cannot avoid comparing it to the situation in Rust land. Rust famously has not less (o
by afdbcreid 3mo ago
This post is really interesting. As a member of the rust-analyzer team, I cannot avoid comparing it to the situation in Rust land. Rust famously has not less (or even more) sophisticated system for incremental compilation, yet its compilation is way slower. I attribute that to two main things:
- Language design. Zig was designed for fast and incremental compilation, Rust is just not. For instance, the post states that Zig has four properties (layout, type, value, body) that the compiler has to track for changes. Rust has much more, to the point that tracking them statically is just impossible, so the compiler uses a query system that tracks them dynamically, which adds overhead.
- Compiler implementation. Rust is much more complicated to compile than Zig, and rustc is both older and bigger (10x-20x LOC) than the Zig compiler, making changing it way harder.
- lsuresh 3mo agoIsn't most of Rust's compilation overhead from the llvm backend?
- afdbcreid 3mo agoThat is common wisdom but reality is more complicated. It's true in some projects, but not all.
- simonask 3mo agoEvery analysis of the problem I've seen has concluded that the main problem is that rustc generates a lot of input to LLVM. Efforts to reduce compilation times are currently focused on doing more to the IR before converting it to LLVM IR. Rust as a language is even more reliant on monomorphization and inlining than C++, due to core language traits such as Deref, AsRef, From/Into, and so on. That said, in practice my personal experience has been that Rust compares pretty favorably on compilation speed, even to some high-level languages like C#. On many developer machines, the actual slow part is linking.
- afdbcreid 3mo agoSee https://kobzol.github.io/rust/rustc/2024/03/15/rustc-what-takes-so-long.html https://kobzol.github.io/rust/rustc/2024/03/15/rustc-what-ta..., which does an extensive analysis on that.
- steveklabnik 3mo agoThis analysis is great, and I don't mean to knock it, but one of the things that it doesn't capture is, what choices does the frontend make that impact the amount of work that the backend does. That is, some of the work attributed to the backend could be improved without touching the backend.
- afdbcreid 3mo agoThat is of course true, but if anything that just proves more what I said. Also that too is part of the "common wisdom" (that as I said, is not always true).
- steveklabnik 3mo agoI wasn’t trying to disagree at all :)