|
|
|
|
|
by eru
5605 days ago
|
|
Yes. Arguing that immutability is possible in Java, is a bit like arguing for good code in PHP. It's possible and advisable. But Java naturally tends towards mutability. And you will have to work harder to make it immutable. Java also does not give you as many tools for this kind of style as functional languages usually give you. First class functions, a rich type system and a library full of immutable data types come to my mind. |
|
Worse, OOP tends to hide the mutable state away internally in objects (or in objects stored inside objects etc) - OOP's data hiding and abstraction support can go against you here. Sure, good programming practices and discipline (eg, const correctness in C++) helps, but the languages definitely encourage mutable state.
I wonder how using methods-as-messages and turning OOP into a message passing system not dissimilar to the actor model would work in practice (both from a usability/syntax and concurrency view).