Comment by pornel
3 years ago
I get it about Rust, because Rust really won't let you hide the fact that you're holding on to a temporary reference (GC is an abstraction over lifetime of objects). Borrow checking is also intentionally less flexible about getters (allowing library author to do anything in the getter, but that makes exclusive-mutable getters exclusive over the whole object not just one field). So Java programmers are in for a shock — public fields are encouraged, and APIs have to commit to a particular memory management strategy.
But OTOH not having to worry about defensive programming is so great. Nothing is NULL. Nothing will unexpectedly mutate. Thread-safety is explicit. It's always clear when vectors and objects are passed, copied, or only briefly inspected.
Welcome to ML derived languages with tracing GC, specially pure ones.
Java isn't the be all end all of GC based languages.
I'd think that if you're dealing with immutable data/pure functions GC becomes transparent even in Java ?
Yeah, however even with using Scala/Clojure, there is the possibility to touch parts of the standard library that fail to uphold such expectactions.
So then one ends up with the usual issue of guest languages, where one needs to create wrappers for the platform APIs to keep the code idiomatic and language invariants.
Controlling mutation by completely abolishing it is one way to go, but often inefficient. Rust gives you a nice third way.