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

Exactly. Object oriented languages of this generation even embraced mutability. The idea was that by having encapsulated/hidden data, methods could validate data and make sure that objects are always in an inconsistent state, hence making mutability safe. (Of course, the same can be achieved in C with opaque pointers.)

It was only until concurrency/parallelization/multi-core became more important that immutability-by-default gained much traction.

Nowadays, Java feels like the victim of the OO hype: mutable by default, static methods being the only escape hatch from OO, only predefined value types (yes, I know, Java 9). People always say that Go is like pre-generics Java, but it at least doesn't make two of the aforementioned mistakes.



> make sure that objects are always in a consistent state

This only works for invariants that constrain the state of a single object. Realistically, invariants that constrain the state of multiple objects are a necessity, and no amount of in-object validation will help you enforce those.




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

Search: