10 ms·
> How do you get anything done when the cost of testing an idea is several hours?! My Rust compile times are usually between 10 and 30 seconds. Some tricks tha
by ekidd 5y ago
> How do you get anything done when the cost of testing an idea is several hours?!
My Rust compile times are usually between 10 and 30 seconds. Some tricks that help:
- Get a good development machine. I prefer a Dell Precision laptop from the last couple of years, with plenty of cores. A 5-year old laptop with 2 cores will be a lot slower.
- Use Visual Studio Code and the rust-analyzer plugin. This will give you feedback in the editor while you're working.
- Rely on the type system to identify most problems before ever generating code.
- Minimize the use of slow-to-compile libraries that rely on complex generic types. Diesel, for example, is a great library but it's slow to compile.
- Install cargo-watch, and use it to automatically re-run the tests.
Also, remember that incrementally re-compiling a single crate in debug mode will be much faster than building an optimized application and all its dependencies from scratch.
TL;Dr: Rust compilation times are less than ideal, but with a fast laptop and rust-analyzer, it's possible to spend very little time actually waiting for the compiler.
- remix2000 5y agoJust get a new machine for a couple zillion bucks, why haven’t we thought of it earlier? :^)
- ekidd 5y agoYes. If you are a professional developer who gets paid to work on large Rust projects all day long, then a US$2500 high-end laptop will pay for itself many times over. (I'm assuming US or European salaries here.) I've gotten by with much less for personal projects. But Rust will make very efficient use of (say) an 8-core i9 if you have one.
- isaacimagine 5y agoAs a developer who uses Rust a bunch (work & personal), this is what I ended up having to do. I'm joking, but this one simple trick can cut compile times in half.
- edflsafoiewq 5y agoYeah, can really see that "empowering everyone" motto coming into play.