Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Go structs are copied but not deeply; collections are inherently passed by reference and everything is mutable. Scala and Kotlin get immutability right and Java is getting there with unmodifiable collections and records.


I don't know that I'd say Scala gets immutability right in that it still provides you equal access to the mutable collections (and I have basically no experience with Kotlin), but I cede the point it's way better than either Go or Java here. I readily admit Golang gets this wrong, just, -slightly- better than Java. I'm coming from an Erlang background, and that's the main influence I'm looking at concurrency from; the JVM as a whole gives me a sad when it comes to helping me write correctly behaving code.


It might be equally accessible, but mutable collections require you import classes from scala.collection.mutable that have very different names, e.g., mutable.ArrayBuffer vs List.

The path of least resistance in Scala leads to immutable collections.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: