3 ms·
> OO is not about state OO is very much about state, and that's the fundamental difference between non-FP languages and FP. a1 = object.f(b); a2 = obj
by pka 8y ago
> OO is not about state
OO is very much about state, and that's the fundamental difference between non-FP languages and FP.
a1 = object.f(b);
a2 = object.f(b);
If a1 != a2 or f performs any side effects at all you've got state. Doesn't matter if it's "private" or "hidden". Your functions are not referentially transparent.
It also doesn't matter if your language implements OO in terms of message passing (Smalltalk, Erlang) or method calling (Java, C#, ...).
- millstone 8y agoThis is orthogonal. Many languages traditionally considered functional do not enforce referential transparency, and nothing prevents you from building referentially transparent functions in an OO language.
- addicted 8y agoNot speaking specifically about this situation, but just because a language considered functional implements a certain behavior doesn’t mean the behavior is functional. The causation usually works the other way. It’s because a majority of the behaviors a language implements are functional that the language is considered functional. As an example, you can write procedural code in Java, which is the poster child of OOP programming. That does not make the procedural code OOP.