3 ms·
The notion that "OO is polymorphism, FP is referential transparency" are caricatures that annoy more than inform. Let's try to avoid that reduction. One better
by millstone 9y ago
The notion that "OO is polymorphism, FP is referential transparency" are caricatures that annoy more than inform. Let's try to avoid that reduction.
One better reduction is OO as objects / FP as abstract data types per Cook's well-known paper [1]. This argues that the key difference is when the transition from abstract to concrete happens. The ADT approach is to do this in the "observations", e.g pattern matching destructuring. But objects do this in the "constructors", the class that gets set when the object is created.
In this view objects and ADTs (OO and FP) are competing, not not orthogonal. Concretely you have to decide whether your C function switches on a tag, or dispatches through a vtable. Which paradigm to prefer depends on the properties you want from your model: dynamic extensibility, efficiency, security, etc. are all considerations.
1: http://www.cs.utexas.edu/~wcook/papers/OOPvsADT/CookOOPvsADT90.pdf http://www.cs.utexas.edu/~wcook/papers/OOPvsADT/CookOOPvsADT... (PDF!)