Hacker News new | past | comments | ask | show | jobs | submit login

So will rust-analyzer also replace rustc eventually as the main rust compiler? Seems like a lot of overhead to keep two compiler versions at parity.



No, the goals of an IDE-oriented compiler are largely different from the goals of a bulk code compiler. They can / will share substantial amounts of code though. Quoting a developer:

>>>>>>>>>>>>>>>>>>>

Aleksey Kladov: The limitations here are not specific to the Rust language, but a general for command line vs IDE compiler.

The main thing is that the command line (or batch) compiler is primarily optimized for throughput (compiling N thousands lines of code per second), while an IDE compiler is optimized for latency (showing correct completion variants in M milliseconds after user typed new fragment of code). As usual with throughput vs latency, these two goals require pretty different optimizations (and even high-level architectures). In general, it's hard to retrofit low latency requirement on a compiler which was developed solely with big throughput in mind.

Another thing is difference in handling invalid code. A traditional compiler front-end is usually organized as a progression of phases, where each phase takes an unstructured input, checks the input for validity, and, if it is indeed valid, adds more structure on top. Specifically, an error in an early phase (like parsing) usually means that the latter phase (like type checking) is not run for this bit of code at all. In other words, "correct code" is a happy case, and everything else can be treated as an error condition. In contrast, in IDE code is always broken, because the user constantly modifies it. As soon as the code is valid, the job of IDE ends and the job of the batch compiler begins. So, an IDE-oriented compiler should accommodate an incomplete and broken code, and provide IDE features, like completion, for such code.


rust-analyzer is not a compiler. They plan on sharing a lot of code though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: