Sending message to non existing process is success but not Non Existing Registered Process, why?

I see no error while sending messages to nonexisting processes using process identifier(pid), but when I send a message to a registered process that is nonExisting, I get an error.

Could someone explain what happens in both cases?
At first, case, why it is allowed to send messages to non-existing processes?

1 Like

why it is allowed to send messages to non-existing processes?

When using distributed Erlang/Elixir, it is very hard/impossible to know if the process on another node is alive or not. Also, that information is not very useful as the process may die a nanosecond after the message is delivered, so there are not that many useful conclusions you could draw from that information.

when I send a message to a registered process that is nonExisting, I get an error.

This is an unfortunate design mistake done a long time ago in Erlang. If we had designed the language today, sending to a non-registered name would behave the same as sending to a non-existing process. I don’t know why the original design was made the way it was. There is too much code relying on this behaviour for it to be changed now.

8 Likes