Re:Single Writer Principle (2011)
by ncmncm on Monday May 11, 2020 @05:15PM
(#23147167)
Ultimately there is no real difference between function calls and message-passing. It is a matter of emphasis.
When you design with message-passing in mind, you don't expect an immediate answer to the message; instead, you expect to get an answer as another message. In some cases, this adds overhead: two messages, vs one function call. In others, you can do something else useful immediately after sending the message, and handle the return message whenever it arrives, maybe much later.
It is common to overlay a function calling mechanism on top of message passing. This is called "RPC", and is often a bad idea. The failure modes of message systems differ from those for function calls, so that assuptions higher up in the abstraction tend to be wrong.
When you design with message-passing in mind, you don't expect an immediate answer to the message; instead, you expect to get an answer as another message. In some cases, this adds overhead: two messages, vs one function call. In others, you can do something else useful immediately after sending the message, and handle the return message whenever it arrives, maybe much later.
It is common to overlay a function calling mechanism on top of message passing. This is called "RPC", and is often a bad idea. The failure modes of message systems differ from those for function calls, so that assuptions higher up in the abstraction tend to be wrong.