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

This requires some explanation. What limitations are people working around here?

If you mean immutability, it's doesn't make sense to single out Java, since immutability was not significantly valued by any mainstream language until the 2000s (of course Haskell and various MLs existed before, but I'm talking about popular mindshare).



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: