4 ms·
It really isn't, as OOP languages don't traditionally provide robust mechanisms around immutability. And why would they? The core design of OOP is to wrap mut
by MasonOfSpoons 6y ago
It really isn't, as OOP languages don't traditionally provide robust mechanisms around immutability. And why would they? The core design of OOP is to wrap mutable state behind methods which control that mutation. OOP was in many ways a reaction to C; shared mutable structs are harmful, so let's invent privacy.
Most of the languages which are suggested to be superior alternatives to OOP in this thread have immutable data records and algebraic data types as core building blocks. These are very different than C-style structs, as they can provide stronger safety guarantees without a massive ream of boilerplate.
A class or method interface promises unfortunately little around essential topics like mutability, concurrency, or termination.
- pjmlp 6y agoYou can already do that via modules or fake modules in C translation units. What OOP offers on top of modules is extendability and polymorphism. And these two capabilities are possible to achieve in various ways.
- jayd16 6y ago>The core design of OOP is to wrap mutable state behind methods which control that mutation. That is the mechanism for immutability that is traditionally provided. It is easy to opt out of that protection. Java and C# are getting records. They're a convenience but are in no way opposed or counter to OOP.