3 ms·
FFS, this isn't that hard to understand. What is your language background? The core difference is that messages are interpreted by the object itself. At runtim
by gambler 8y ago
FFS, this isn't that hard to understand. What is your language background?
The core difference is that messages are interpreted by the object itself. At runtime.
Here is a practical example where the difference is obvious. Let's say you have an object that does business logic. You want to log all of its operations without changing its logic or the code that calls it.
In a method call language, this is a pain in the ass. You have to subclass the original class, override every single method, and call the original logic + logger in every single one of those methods. And after all that work all you get is a lousy logger that's just good for one class and needs to be modified if you add something to the original class.
In a message-passing language, you would create a proxy class that passes all of its messages to the original object, then calls the logger. This implementation would involve writing only one method and would be applicable to absolutely any class/object in the system.
And this is just one out of many, many instances where message-passing allows for elegant solutions while method calls make you miserable.