logoalt Hacker News

aw1621107today at 5:35 PM0 repliesview on HN

> but I had heard that the compiler is slow (because it's doing so much thinking and checking in advance).

The compiler is indeed not particularly speedy, but the reason you were given is not entirely accurate. As measured in this blog post [0] different parts of the compilation pipeline will take different amounts of time depending on what you're doing (cargo check vs. incremental build vs. full build, building a library vs. binary, etc.), but generally speaking type/borrow checking take up relatively small portions of compilation time (~15% or less, based on eyeballing the charts [1, 2]) compared to everything else.

> one that's optimized for such tight loops, and another that does thorough checking

I think that would risk producing diverging language subsets, especially if the checks are essential for language semantics. For example, what exactly does it mean if a program passes the "relaxed" compiler but fails the "thorough" one? How close does that actually get you to a "real" working program?

[0]: https://kobzol.github.io/rust/rustc/2024/03/15/rustc-what-ta...

[1]: https://kobzol.github.io/assets/posts/compile-sections/binar...

[2]: https://kobzol.github.io/assets/posts/compile-sections/libra...