3 ms·
I'm thinking the closest mainstream thing to real messages is probably event handling. Events are nearly always represented as objects of some sort (rather than
by skybrian 10y ago
I'm thinking the closest mainstream thing to real messages is probably event handling. Events are nearly always represented as objects of some sort (rather than something simpler like a function call) and event routing is the heart of any UI framework.
So maybe the question is whether we should be using events (and streams of events) more?
But this doesn't seem like a neglected area - publish/subscribe is pretty common and there's plenty of recent discussion of reactive systems and event-handling architectures.
- grandalf 10y ago> But this doesn't seem like a neglected area It is generally considered a suited for a different class of problems. I think Kay's point is that decoupling the messages from an object's internal state is a smart approach to system design. Many of the other "features" of OOP get in the way of this design principle.
- Joeri 10y agoIt is much broader than events. Anything where you sit and wait for some piece of data to happen and trigger code can be viewed as receiving messages. An object that sits in memory and has its methods called is receiving messages. A piece of code that calls methods on objects is sending messages. A variable containing data is a message at rest, and once passed to a method becomes a message in transit. If you then start thinking about things like generators, you see that this is just another way of sending messages. You can take any program and view it entirely as a collection of messages, with the objects and procedures being the glue between the messages. The issue that languages have, is that the syntax obscures this fact instead of highlighting it. There are many different ways of sending a message between objects, and none of them are labeled as such. But essentially, there are just two different models that matter: synchronous send + receive (receive the replied message, the method's return value, before moving on), and asynchronous send + receive (where the receive remembers the context of what was sent that is being replied to). A really simple OO language would just implement those two operations between objects, and would need nothing else.