Remix.run Logo
▲ nu11ptr a day ago

The Rust compiler, while not extremely fast, is not extremely slow either. As an example, my toy compiler is 130K LoC of Rust and compiles in under 7 seconds on a cold build on my M5 Max. An incremental build is nearly instant. So then why is it that so many projects have a minute compile time with far fewer LoC?

The answer: dependencies (My compiler has virtually none, intentionally)

Rust has a very small stdlib, so you are forced to bring in dependency crates, and not just a few. Many programs have 50-100 or more, and they all have dependencies, and so on. Contrast with Go where it has a culture of few dependencies, and those project have few dependencies. Your Rust compiler is doing a lot more work for what appears to be the same program as in other langs, but ultimately is a lot more code (typically).

To make matters worse, cargo does a decent job of parallelizing the builds, but it can only do so a) at the crate level b) only as much as the dependency graph allows.

▲Twirrim a day ago | parent | next [-]

I love the language, but I'm still not convinced by Rust's skinny stdlib approach. I appreciate not wanting to end up like python where they're having to remove stuff from the stdlib because it has too many batteries and bitrot is a problem, but there's surely a happy-medium somewhere along the line.

I don't write much Go but it seems like it has a good balance when I do.

It may be a bad example, but even in rust generating a random number involves pulling in 6ish crates

   └── rand v0.10.3
    ├── chacha20 v0.10.2
    │   ├── cfg-if v1.0.5
    │   └── rand_core v0.10.1
    ├── getrandom v0.4.3
    │   ├── cfg-if v1.0.5
    │   ├── libc v0.2.191
    │   └── rand_core v0.10.1
    └── rand_core v0.10.1
▲coderenegade a day ago | parent | next [-]

The skinny stdlib is always a mistake imo, because if you don't provide it, somebody else will, and it's unlikely to be as nice to work with for your users as a standard library implementation. In the case of C++, for instance, this lead to the boost era.

For all of Python's warts, it at least makes everyday structures and operations you might want to use fairly painless, and it keeps expression fairly standardized. Leave external libraries to build things that are actually interesting, rather than scaffolding and infrastructure that the language vendor is better off providing.

▲imtringued 15 hours ago | parent [-]

>The skinny stdlib is always a mistake imo, because if you don't provide it, somebody else will, and it's unlikely to be as nice to work with for your users as a standard library implementation. In the case of C++, for instance, this lead to the boost era.

I disagree, skinny stdlib is an option that you intentionally leave open. You let the ecosystem around you explore good solutions first before you commit early or exhaust the air in the room for better ideas.

▲pipe01 12 hours ago | parent [-]

That would be fine if rust actually did commit to something

▲nu11ptr a day ago | parent | prev | next [-]

Agreed. I would like to see an extended stdlib of sorts form perhaps taking inspiration from Go or Python. I think it is too late to shim it into the language itself, but it could be like an alternative stdlib of sorts (more like an addendum, not replacing what is already in stdlib). The bonus is it would be precompiled for all platforms so even if doing a cold compile, it just is linked.

▲cmrdporcupine a day ago | parent | prev [-]

100% this. Was playing with the odin language recently (https://odin-lang.org/) and was very pleased at what was included in the std lib while still being a good viable systems PL. And delightful fast compilation time.

That said, I missed the borrow checker.

▲pjmlp a day ago | parent [-]

And a certain Object Pascal feel to it, while the provided library is not on the same vein as MacApp, Turbo Vision, or OWL.

▲mpweiher 17 hours ago | parent | prev | next [-]

> The answer: dependencies

Assuming for a second this is true.

Why?

We solved separate compilation a few decades ago. So if those dependencies are causing your compile times to spiral out of control, then something is wrong.

For example unlearning separate compilation, as we seem to have done.

▲shikck200 21 hours ago | parent | prev [-]

> M5 Max

Fucking lol. I have an almost decade-old laptop and compile projects way faster. Ocaml and Go both compile 100K LOC projects under 1sec.

▲pjmlp 19 hours ago | parent [-]

That is what I always point out, not everyone on the planet can afford the kind of hardware that makes Rust builds usable, thus it is a potential loss of users that are then pushed into adopting languages that are friendlier in hardware requirements.

And to make a point, the Turbo Pascal 5.5 compilation times, from 1989 marketing brochure

> Fast! Compiles 34 000 lines of code per minute

This was measured on a IBM PS/2 Model 60, a computer model from 1987, with a 80286 running at 10 MHz, limited by 640 KB, with luck one would expand it up to 1 MB and use HMA, in what concerns using it with MS-DOS.

You can get the brochure at https://archive.org/details/bitsavers_borlandtur5.5Brochure1...

So one would expect that at very least for debug builds in 2026, one would always have blazing fast build times.

Which is why languages like OCaml, Go, Zig, D, Delphi and co, are not doing something spectacular, rather pretty much what should be the norm, and unfortunately got sidetracked somehow.