3 ms·
> You don’t mutate by default. > makes illegal states unrepresentable Maybe recent versions of Java are different, but I don't recall either of those statemen
by bachmeier 5y ago
> You don’t mutate by default.
> makes illegal states unrepresentable
Maybe recent versions of Java are different, but I don't recall either of those statements applying when I used Java.
- odyssey7 5y agoThe whole idea of OOP is you have mutable data coupled with the methods that mutate it.
- cryptonector 5y agoYou can do immutable data structures with OOP. The problem is that you can also do mutation.
- zdragnar 5y agoCompilers / runtimes for most OOP languages don't really put the same level of optimization into operations with immutable structures as they do with mutable ones, because the mutable paradigm is largely how the languages are (intended to be) used. There are exceptions, of course, but you are leaving a lot on the table when you try to shoehorn one into the other.
- twic 5y agoJava doesn't force you to do either of those, but it allows it, and doing so has been standard programming advice in Java for at least a decade. See item 13, "Favor immutability", in Effective Java, the bible of Java programming, published in 2001: https://www.pascal-man.com/navigation/faq-java-browser/java-concurrent/Effective_Java.pdf https://www.pascal-man.com/navigation/faq-java-browser/java-... I can't find a concrete citation for "makes illegal states unrepresentable" (does anyone know the history of this phrase?), but it was certainly part of conversations i was having in 2012.
- bachmeier 5y ago> Java doesn't force you to do either of those, but it allows it, and doing so has been standard programming advice in Java for at least a decade. "You can do that" and "enforced by the compiler by default" are pretty different.
- marshray 5y ago"Make illegal states unrepresentable" is usually attributed to Yaron Minsky of Jane Street. This video shows it at 28:02. https://blog.janestreet.com/effective-ml-video/ https://blog.janestreet.com/effective-ml-video/ https://www.youtube.com/watch?v=-J8YyfrSwTk https://www.youtube.com/watch?v=-J8YyfrSwTk