▲ | anamexis 12 hours ago | ||||||||||||||||
I’m a rubyist, but how is message passing fundamentally different from method calling? I get that method_missing adds a twist, but your comment doesn’t explain what the fundamental difference is. Especially in the context of Fixnum#times. How does message passing vs method calling matter there? #times is just a method on Fixnum. | |||||||||||||||||
▲ | isr 10 hours ago | parent [-] | ||||||||||||||||
Because it leaves it up to the object being called what to actually do with the message. The object you're talking to might be forwarding its messages to another object in another ruby instance on another machine (if the current machine is getting fully loaded, etc), and the caller would be none the wiser. And crucially, the caller wouldn't have to be modified to enable this. The logic for this would be entirely within the object being called. So the difference isn't just with method_missing. With "method calling" as you put it, the program blows up if that object doesn't have that method, WHEN YOU CALL IT. Basically, this smalltalk oo paradigm is about shifting where you put more of your logic. At & around the "call" site, or within the object whom you're calling & entrusting to do something useful with it. All hearkening back to Alan Kay's original ideas about biology influencing how we organise code, and having a program be 1000's of "little black boxes" where work gets done by all these boxes talking to each other. Which is why smalltalk (& ruby implements the Smalltalk object model to its entirety) actually has an awful lot in common with Erlang & other BEAM runtimes, even though those are functional languages. Because once you get beyond the techy buzzwords, the main ethos behind them is actually quite similar. | |||||||||||||||||
|