3 ms·
> For line of business apps, it is inaccessible and the safety dial is turned up too far. My employer has a "line of business app" written in Rust. Here's what
by ekidd 10y ago
> For line of business apps, it is inaccessible and the safety dial is turned up too far.
My employer has a "line of business app" written in Rust. Here's what we're learned:
1. Rust does have a learning curve. It's easier to learn to use well than C++, in my opinion, but certainly harder than Ruby or Java. You really, really need to budget 2 weeks for turning an existing C++ developer into a productive and confident Rust developer. You can't take somebody who doesn't know the difference between "stack" and "heap", or who has never passed an anonymous function to "map", and expect them to bang out code rapidly in two days.
2. The library situation for business apps is just barely adequate. We need support for PostgreSQL, RabbitMQ, REST APIs, etc. In each case, high-quality libraries exist, but they're usually missing something. (For example: For PostgreSQL, we need to use both 'postgres' and 'diesel' to get the feature coverage we want. For RabbitMQ, we don't have heartbeat support. For REST APIs, we won't have good HTTP request mocking until the Hyper async stuff sorts itself out. And so on.)
3. The Rust code is just ridiculously fast. We're processing gigabytes of data, so we love this.
4. The Rust code is remarkably "trustworthy", and I'm not just talking about memory safety. If your program even compiles, it almost always works correctly (assuming you understood the spec). This has at least as much to do with Rust's 'enum' and 'match', which encourage people to enumerate and handle all cases, as it does with the borrow checker.
5. Rust code is very pleasant to maintain and refactor once written.
Overall, we like Rust, but we're mostly only using it where (a) we really want performance, or (b) we really want to make sure we handle lots of tricky corner cases correctly. Oh, or (c) for long-running jobs that take hours to run on real data, where compiler correctness-checks are a huge win. We'll probably gradually use Rust in more places as we get experience and the tools mature.
- plinkplonk 10y agoThis is a great experience report. Thank You (spoken as someone on the verge of taking the plunge into Rust, but getting stuck on lack of documentation on unsafe etc)
- ekidd 10y agoI don't think we have a single line of 'unsafe' code in any of our 6 Rust projects at work. If you're using Rust for business apps, you'll basically never touch 'unsafe'. For an extreme example from a weekend project, I wrote an MPEG 2 Program Stream / Packetized Elementary Stream / subtitle image decompressor, which obviously does a lot of bit-banging. (It's an ugly old format.) And I never touched 'unsafe' once. This is typical. The only big exceptions are (1) working with existing C libraries, which isn't too hard once you get the hang of it, but which obviously requires 'unsafe', and (2) writing your own graph-like data structures from scratch, which you should avoid in favor of using an existing library like petgraph (https://docs.rs/petgraph/0.4.3/petgraph/ https://docs.rs/petgraph/0.4.3/petgraph/). Basically, a doubly-linked list or cyclic graph is the worst possibly introduction to Rust for newbie Rust programmer. Start with something easier! I mean, unless you're the kind of person who tries to pole-vault learning curves, in which case, have fun.
- moosingin3space 10y agoIf you _really_ want to learn how to use Rust to write graph-like data structures, look at this: http://cglab.ca/~abeinges/blah/too-many-lists/book/ http://cglab.ca/~abeinges/blah/too-many-lists/book/
- el_isma 10y ago> I wrote an MPEG 2 Program Stream / Packetized Elementary Stream / subtitle image decompressor, which obviously does a lot of bit-banging Are you open sourcing this? I'd love to take a look
- deleted 10y ago[deleted]
- kazagistar 10y ago> This has at least as much to do with Rust's 'enum' and 'match', which encourage people to enumerate and handle all cases This is something I agree with strongly, and have had a hard time explaining to Java devs.
- killercup 10y agoThanks for the great report! I'm looking forward to seeing how Rust (as well as its standard library) will be tweaked to become easier to learn (which is a goal for 2017). I don't think you'll be able to reduce these 2 weeks to 2 days this time next year, though. You are one of the first people/companies using diesel in production, btw, which is really awesome! I hope we can help you get rid of your dependency on plain postgres sooner rather than later :)