4 ms·
I write web services in Rust. I'm extremely productive in Rust vs other languages, especially for young projects where I spend a lot of time refactoring. Thing
by staticassertion 8y ago
I write web services in Rust.
I'm extremely productive in Rust vs other languages, especially for young projects where I spend a lot of time refactoring. Things like borrow checker errors just don't happen very often to me anymore, or they catch legitimate bugs and are generally quite easy to fix. I just don't run into them very often at this point.
I've written Python and Java professionally. In both cases I felt like I just couldn't express what I wanted to, at all times, in my program. This led to me being a lot less comfortable refactoring - relying on tests that were far too heavily tied to implementation details.
I had some really complex logic I needed to write for one of my services. Basically I needed to represent a 'thing' and that 'thing' could be in a few different states. I wrote out the code, types first, so that every state had a type. I was able to do this generically using Rust's associated types in a way that allowed me to implement the state machine for multiple 'things'. It was very testable, very readable code that I had high confidence in. I would have had a much harder time doing this in Java/ Python (I have done similar things, and you can get value from the approach, but not the same level). I've refactored that code a lot with confidence.
Speed is a nice bonus, but mostly secondary.
- kbenson 8y agoCan I ask what you use as a database abstraction layer, if any, and what methods you use to convert your request params/JSON to queries? I was playing around with trying to do this a while back (while also trying to learn Rust some), and it felt very cumbersome to have to write many specific Diesel update methods to handle different types of requests. It could have been my now knowing a better way to accomplish it, or it could have been the type of queries I was trying to model aren't a good fit for a staticly typed system like that (and there may be a better way to architect it). In any case, it felt like I was poorly approximating the strict typing I had already implemented in Postgres, a few times over, when I would be happy just handing it to Postgres and letting it throw out errors as needed.
- staticassertion 8y agoThe only data stores I currently use are redis and dgraph. I write raw dgraph queries, though I have a small, highly focused library that I use to generate some of them. As for redis, I use it as a dumb KV store, no need for an abstraction layer.
- lazharichir 8y agoDgraph is awesome but lacking some serious basic features such as backups and automatic file format update on new versions. I hate to export it all, update, re-import... But love it, and love the team at Dgraph/Badger.
- staticassertion 8y agoYes, it's young and that shows in some places. But I think the team has done an excellent job and it happens to fit my use case very well.
- Koshkin 8y ago> I'm extremely productive > I spend a lot of time refactoring Isn't that a contradiction?
- staticassertion 8y agoNo. I would be refactoring in any language - the idea behind the service, the requirements, etc, are changing a lot as I'm building these services out. These are external factors that would exist regardless of the language, as I continue to explore the problem space.
- sargun 8y agoHave you written Erlang?
- staticassertion 8y agoNot anything serious, no. I'm decently familiar with it though - I'm fascinated by the actor model, and have read a decent portion of Joe Armstrong's thesis.