News for hackers. Stuff that matters.
Re:Two Years with Rust by giovannibajo1 on Monday March 23, 2020 @09:03AM (#22663681)
I’m writing a largish (~15k) hobby program in Rust. I’ll focus on negative points, there are many positive.

Compilation time is terrible, I need something between 20 and 40 seconds for edit-compile-cycle (MacBook Pro 2016, i7, 16gb ram) which kills productivity for me especially since as a hobby I tend to have small windows. I should probably dedicate time to investigate how I can speed it up (split it in more crates than naturally required, refactor how tests are written, etc) but this is a turn down by itself.

Productivity is still low. Even after writing so many lines I still can’t feel productive; I still face problems writing code that compiles, and am forced to workaround issues with partial borrowing of structures, or similar issues. This happens anytime I need to do something “new” form an architectural point of view (writing a new “component”), or if I attempt something “smart” (eg, trying to refactor to reduce duplication). This matches what this article said: Go is far more productive for me. If the architecture is fixed and I just “write the code in the right place”, then I can get decent speed (modulo the compile time issue).

Re:Two Years with Rust by cesarb on Monday March 23, 2020 @10:03AM (#22664173)
> Compilation time is terrible, I need something between 20 and 40 seconds for edit-compile-cycle (MacBook Pro 2016, i7, 16gb ram)

A trick available on newer releases of rustc is "cargo check", that stops the compilation before the code generation (which is the slow part). If all you need at the moment is to see whether it would compile (no syntax errors, no wrong types, no borrow check errors), it can help a lot.

Re:Two Years with Rust by staticassertion on Monday March 23, 2020 @03:13PM (#22667610)
I also work on a ~15kloc rust project. I use cargo check all the time. Still extremely slow, not to mention that my whole system can be locked up by rustc, which really kills development.

I'll probably find a way to cgroup rustc just to deal with this issue.

Re:Two Years with Rust by pimeys on Monday March 23, 2020 @04:33PM (#22668440)
I solved this by building myself a 3950x workstation. 16 cores and 32 GB of RAM does miracles for Rust workflows.

That and the guidance kouteiheika gave above puts you far already.

Re:Two Years with Rust by pjmlp on Monday March 23, 2020 @05:25PM (#22668940)
Which means other system languages will continue to thrive for developers not so lucky with Rust compiler rigs.
Re:Two Years with Rust by pimeys on Monday March 23, 2020 @06:00PM (#22669277)
The funny thing is I paid about the same from my rig that people pay for a Macbook Pro. It is not really unaffordable and you get a great development machine.

Of course nowadays the combination of Emacs and rust-analyzer gives you a very fast and nice workflow. That and one terminal running

  cargo watch -s 'clear; cargo check --tests --color=always 2>&1 | head -40'
works miracles.
Re:Two Years with Rust by staticassertion on Monday March 23, 2020 @04:52PM (#22668621)
Yeah I have 8 cores(HT) and 16GB, which is apparently just not enough.

I think my plan is to just move builds to some kinda EC2 instance that I can bulk up.

Re:Two Years with Rust by pimeys on Monday March 23, 2020 @04:57PM (#22668661)
It's probably just the thermals. A desktop CPU runs circles over any laptop due to tremendously better thermals and power window.
Re:Two Years with Rust by staticassertion on Monday March 23, 2020 @05:04PM (#22668729)
It's possible, but my laptop runs fairly cool - it's elevated on a stand and is 18 inches, with a lot of ventilation. Of course it doesn't compare to a desktop system, but even still, this thing is hardly weak. It's a bit absurd to require 16 cores and 32GB of RAM to be productive.
Re:Two Years with Rust by leshow on Monday March 23, 2020 @12:26PM (#22665536)
If you divide the project up into sub crates, using a "workspace" you can improve compile times. If you're not using that feature already. Not saying that compilation speed isn't an issue, but that's one thing that can help.

Sibling comment mentioned `cargo check` which is pretty fast too. If you use an editor with a decent rust plugin like vscode (using RLS or rust-analyzer). It will run `cargo check` by default for you.