3 ms·
> I'd like to hear something like "This is how our team used Rust to do (really hard thing involving heavy concurrency and lots of state)". Our team uses Rust
by ekidd 8y ago
> I'd like to hear something like "This is how our team used Rust to do (really hard thing involving heavy concurrency and lots of state)".
Our team uses Rust for moderately complex concurrency.
TL;dr: There are tradeoffs, but Rust can be quite nice when you care about performance.
In my experience, concurrency is actually pleasant in Rust. The borrow checker eliminates 99% of problems before they ever occur. As for libraries, the popular crossbeam library provides scoped thread pools, which make it easy to spin up a bunch of local worker threads. https://docs.rs/crossbeam/0.3.2/crossbeam/struct.Scope.html#method.spawn https://docs.rs/crossbeam/0.3.2/crossbeam/struct.Scope.html#... For "parallel iterators", Rayon is excellent. https://github.com/rayon-rs/rayon https://github.com/rayon-rs/rayon For async I/O, the tokio library still demands solid Rust skills (at least until Rust 2018 lands), but once you figure it out, it Just Works. https://tokio.rs/ https://tokio.rs/
As for our other experiences using Rust:
- Rust is amazing for fast, cross-platform CLI tools.
- For most kinds of programs, I barely notice the borrow checker any more. But this is partly because I don't write programs with giant webs of objects that all try to mutate each other (like some game engines, for example). Also, I've never needed to implement a non-hierarchical data structure in Rust (the gory details of which are described at http://cglab.ca/~abeinges/blah/too-many-lists/book/ http://cglab.ca/~abeinges/blah/too-many-lists/book/), mostly because anything I needed was already on crates.io.
- Library support is much better than I would expect for a young language, but I do occasionally find myself overhauling the guts of an AMQP library or something. This costs me maybe a week or two per year?
Flavor-wise, Rust feels like a simpler C++ without the sharp edges or footguns. It has much better package-management tools. Safe Rust code doesn't have data races or buffer overflows. If you fuzz Rust code, the worst that will normally happen is a controlled panic caused by an invalid array index.
But Rust is going to be more challenging to somebody who has never thought about stack allocation versus heap allocation, or who has never written "my_list.map(some_function)". And sometimes the type names can get a bit hairy, if somebody uses too many parameterized types.
But overall, I'm really enjoying Rust at work. It's basically the language I spent the entire 90s desperately wanting, back when performance was always a big deal.
- oconnor663 8y ago> And sometimes the type names can get a bit hairy, if somebody uses too many parameterized types. `impl Trait` just landed in stable! I think the most interesting use cases (putting an impl Trait in a struct) aren't stable yet? But the basics are working great.