I have been working with functional programming a good bit lately, and have found immutability to offer a different perspective in regard to solving problems. I am considering using immutable classes by default in my future development.
Aside from potentially a small performance cost, why aren’t immutable classes more prevalent as standard convention in normal “good” design? Is there a down side I am not aware of with immutable classes (barring performance)?
I know immutability has been frequently discussed, but I had trouble finding anything specifically addressing why it’s not used more than mutable classes.
I think that’s just because we’re working on Von Neumann model, which is mutable, which brings C programming languages and has huge a mount of derived languages like C++, Java, C#, etc. These languages rules the world and people have been thinking in mutable way for years. We learn mutable programming, we’re taught mutable programming, most of the systems are written now are mutable. Even people and world are mutable.
We’re all (alright, most of us) mutable. We just get used to it.