Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I am afraid that the slow compilation of Rust is rooted to its inherent complexity.

AFAIK that's not the case.

The problem here is that Rust has "issues" with separate compilation due to some language design decisions (which affect incremental compilation than obviously). It's not built for that and it is, and continuously will be, quite difficult to make this work somehow.

But that's less a problem with the complexity of the language as such.

My Scala example stands: Scala is also quite complex and not the fastest to compile. But after the build system and the compiler crunched the sources once (which may take many minutes on a larger code base) the IDE is very responsive. Things like type hints or go-to def are more or less instant. Code completion is fast enough to be used fluently. Edit-compile-test cycles are fast thanks to the fact that separate compilation considerations were part of the language design decisions. (That's for example why Scala has orphan type-class instances; which are a feature and a wart at the same time).

As I understand Rust's "compilation units" are actually crates. This is not very fine granular and I guess the source of the issues.

I would guess splitting code into a few (more) crates (which than need to depend on each other) may improve the incremental build times. Also things like not building optimized code during development of course apply, but I think cargo does this automatically anyway.

But I'm not an expert on this. Would need to look things up myself.

Maybe someone else has some proven tricks to share?

OK, a quick search yielded some useful results, so I share:

https://www.pingcap.com/blog/rust-huge-compilation-units/

https://fasterthanli.me/articles/why-is-my-rust-build-so-slo...

https://news.ycombinator.com/item?id=29742694



Thanks for the detailed answer and the pointed resources!

In fact, I included the lack of compilation locality in "inherent complexity of Rust". However, I agree that this could be considered apart.

In my experience with TypeScript (quite different, I admitted), splitting in distinct compilation unit may help. However, this does not solve the issue.

This could be great if Rust could deprecate some features in order to improve its compilation speed. I am not sure if it is feasible…




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

Search: