3 ms·
This helped congeal a thing I've been thinking about in my Rust usage for a long time, but didn't know how to express: > In Rust, this distinction in register
by brundolf 4y ago
This helped congeal a thing I've been thinking about in my Rust usage for a long time, but didn't know how to express:
> In Rust, this distinction in register can look like this:
> - Will I use references and borrowing, or will I liberally use clone to avoid it?
> In general, Rust strives to have an obvious register which to operate which is still going to be performant enough (and hopefully accessible enough!), while allowing users to switch register when they need to.
One of the biggest ergonomics problems in Rust, in my experience, is that for certain things (like references vs clones, or generics vs enums vs dynamic dispatch), it can be very hard to change registers once you realize you need a different one. Often it means making changes throughout your entire codebase
I don't have an easy solution but I feel like I at least have words for the problem now
- drewtato 4y agoThe strong typing in rust definitely helps with this, though. For most problems, you can encapsulate a refactor into something that, at each occurrence, either works automatically (with things like generics and deref) or fails to compile.
- zamubafoo 4y agoI think Rust is actually pretty good at this. If you do have to do a change that will affect your entire code base (or at least will be pervasive), the compiler will be able to tell you where things are wrong with a good degree of precision.
- brundolf 4y agoIt'll tell you, yes, but you'll still have to make non-automatable changes in a whole lot of different places in many situations. In situations where other languages might not require any changes at all