this post was submitted on 28 Nov 2021
11 points (100.0% liked)
Rust Programming
8306 readers
12 users here now
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Rust is really bad with global side-effects from one object to another. In some regards, Rust is a really good object-oriented language (in the "original" definition) because it has strong typing guarantees, first-class interfaces (traits) and the best (de)serialization library i've ever encountered [0].
But Rust being parallel-friendly by default will prevent you from all sorts of patterns common in dynamic languages (JS, Python, PHP), where all objects hold mutable references to any other object (without clear hierarchy/interface) and anything can be mutated from any part of the program. In single-threaded programming, this kind of object tinkering can lead to unexpected behavior (not undefined behavior) where one tiny function somewhere will have crazy side-effects that will break some other part of the program. But in parallel programming, it's certain to cause all sorts of quirks due to race conditions (two threads accessing/modifying the same data).
In that sense, Rust takes some inspiration from functional programming, and side-effects are declared with mutable pointers (
&mut Type
). So it's still technically possible to do everything you do in a dynamic language in Rust, but the language doesn't make it especially easy. I personally think it's a very good trade-off. Although i'm sometimes bored to write more boilerplate, i can't stress enough how relaxing it is to have your code working expectedly as soon as it compiles. It feels like a superpower.[0] serde. Seriously, serde is so powerful and standard across the Rust ecosystem that writing serialization code in golang/python feels very clunky after trying that out.