by amelius · 3y ago · 0 comments
memory safety, speed, ergonomics
pick two.
Looking at you Bjarne
It might be an interesting strategy to wrap shared objects with Gc<> or Rc<> by default to sidestep the fight. Once you've discovered the slowest parts of your codebase, you could refactor to replace Gc/Rc with zero-cost borrows or well-placed copies.
I haven't tried this myself, but I'm surprised it isn't the standard operating procedure for (non-embedded) Rust programmers.
Now, one might argue that this explicitness is good! But it's definitely an extra bunch of things to type when you're building something where you don't care about memory management.
[0] https://manishearth.github.io/blog/2021/04/05/a-tour-of-safe...
unsafe { std::transmute(x) } is my favorite go to if I’m sure I have the lifetime mechanics sorted and don’t want to fight the borrow checker right now (oh, and usually the borrow checker is right and I think I’ve done this like maybe 2-3 times where it’s really impossible to convey to the compiler what I’m trying to do, at least with my knowledge of Rust)
There's still a tradeoff, but they push the boundaries quite a bit
What are some ergonomic issues, in your opinion?