3 ms·
Another solution is to use immutable and/or persistent data structures. Of course, because golang doesn't have generics, it becomes unwieldy to have a library o
by apta 7y ago
Another solution is to use immutable and/or persistent data structures. Of course, because golang doesn't have generics, it becomes unwieldy to have a library of them, unlike what we see in Java, Scala, etc. where these enjoy a wider adoption.
- sanxiyn 7y agoShared mutable state is evil, so "not mutable" has been proposed as a solution. Rust is different, because Rust's solution is "not sharing". You can still mutate!
- reificator 7y ago> Rust is different, because Rust's solution is "not sharing". You can still mutate! For the record, rust does also default to immutability, and you can share immutable references all you'd like.
- bcrosby95 7y agoI would describe Rust more like a read-write lock than not sharing.
- nine_k 7y agoA lock is acquired and detected at runtime. Ownership and move semantics are checked at compile time, and allow effective "not sharing" without waiting or defensive copies.