4 ms·
The idea that “compile time checks help you write better code is unanimous and absolute” is simply false. Rust itself demonstrates that compile time checks som
by wredue 3y ago
The idea that “compile time checks help you write better code is unanimous and absolute” is simply false.
Rust itself demonstrates that compile time checks sometimes result in worse code, as many people have found especially when they need to do things rust doesn’t like for performance reasons.
For sure, some checks are unambiguously good. But there is also definitely a moving target of a line towards whether or not more checks has diminishing returns if not negative returns on your code. That moving line will depend on a lot of things.
You also need to be careful because “more checks” doesn’t mean “less work” as you’ve asserted. It means more work in a lot of safe pointer scenarios in rust, and more work actually does often translate to more logic bugs and more complexity when anything changes.
As far as I can tell, more checks doesn’t same any time, it often just changes where your time is spent.
- tored 3y agoNot a Rust developer, in what way is Rust forcing you to write less performant code? Any good example?
- grayhatter 3y agoI doubt you'll have anyone take you up on this offer. Goal posts for "good example" get moved every time anyone tries. Anything using Arc is a good place to start though.
- Measter 3y agoThe borrow checker is really at its happiest when your ownership and borrow structure is tree-like, so uni-directional references and ownership, because it's much easier to analyse. If the ownership structure that gives the best performance for your problem is not tree-like, you will run into issues with the borrow checker. There are ways to tackle it: you could keep the non-tree-like structure and use reference counting and RefCells to move the borrow checking to runtime, or its possible you could use a less performant but tree-like structure that the borrow checker accepts, but both of these examples would come at a performance cost. It's kinda hard to be more specific because it's heavily dependent on the exact problem.