Now we have a mutable closure, shared between a bunch of functions (now called methods).
OOP and Functional Duality
OOP and Functional Programming "can" be seen as a dual. They represent the same thing, to a great extent and they try to provide tools to solve the same problem: composition.
What about message passing?
We simply forgot about that - in time. OOP - in its original form - was about message-passing and behavior. And was trying to organize state and transformation through composing behaviors. While the OOP that we have tries to solve the composition problem, through data structures/type - same as Functional Programming.
Behavior has been forgotten.
This was a quick sketch for drafting out these ideas and get them written. Maybe it can be improved, maybe not.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Let's assume that we can question everything that is assumed to be a fact (or ask stupid questions - your take).
OOP was about message passing
Apparently, the language that is most close to the original idea of OOP, is ... Erlang! According to Alan Kay (mentioned this on different occassions).
Closures & Functional Programming
Here, only functions are used. The
factor
constant, is a closure, accessed insideadd10
andmultiply10
functions. Very Functional so far.Factor Out The Shared Closure
An idea: let's factor out the shared closure and put it inside something (we will call it an object later).
Wow! An Object is very much like a bunch of functions with a shared closure!
Last Bit, Mutation
Now we have a mutable closure, shared between a bunch of functions (now called methods).
OOP and Functional Duality
OOP and Functional Programming "can" be seen as a dual. They represent the same thing, to a great extent and they try to provide tools to solve the same problem: composition.
What about message passing?
We simply forgot about that - in time. OOP - in its original form - was about message-passing and behavior. And was trying to organize state and transformation through composing behaviors. While the OOP that we have tries to solve the composition problem, through data structures/type - same as Functional Programming.
Behavior has been forgotten.