Rust's insistence that you manage aliasing in your types leads to better design, in the end.

It's common for programs in other languages to rely implicitly on global variables, or to take an "everything pointer" argument that can be used to reach all sorts of things they may or may not need.

You generally can't take this shortcut in Rust, which is sometimes frustrating when porting programs. Instead, functions generally wind up taking the things they need as separate arguments, and complex functions are less likely to just be hung on "&self."

In addition to eliminating aliasing-related bugs, this makes the code a lot easier to analyze and test, in my opinion. It's basically the same thing dependency injection did at the application level, but for functions. And, yeah, sometimes I have to spend a while thinking about how to shape my code to take advantage of it, but I wind up happier with the result.

0

If you have a fediverse account, you can quote this note from your own instance. Search https://hachyderm.io/users/cliffle/statuses/115538778598176250 on your instance and quote it. (Note that quoting is not supported in Mastodon.)