3 ms·
Interesting, I didn't realize CSP was so specific. I heard someone say that Erlang's model was CSP too. They aren't called "channels" but they're very similar
by freedomben 5y ago
Interesting, I didn't realize CSP was so specific.
I heard someone say that Erlang's model was CSP too. They aren't called "channels" but they're very similar in that you have two different process/threads that are reading/writing to/from an ordered stream that feels the same as reading/writing to/from a Go channel.
What would Erlang's model be called? Does "the Actor Model" cover it?
- Jtsummers 5y agoYes, Erlang is based more on the actor model. CSP is synchronous, so sending to a channel will block if the receiver isn't ready. Erlang and actors are asynchronous in this matter. They will send regardless of whether the receiver is in a state where it can receive the message. Practically, Go (and libmill) allow buffered channels so that you only block if the channel's buffer is full. CSP is based on anonymous processes. Actors have identity, and this would be the process IDs in Erlang. Erlang and the actor model don't use channels (though you can use processes to mimic them).
- masklinn 5y ago> Practically, Go (and libmill) allow buffered channels so that you only block if the channel's buffer is full. Go also allows rendezvous channel (channels with an empty buffer, so either side can only proceed when the other arrives: the actual message exchange is synchronous).
- freedomben 5y agoNice, thanks that makes a lot of sense and definitely an important difference.
- paskozdilar 5y agoTechnically, Erlang is based on Actor model. But both models are formally equivalent, i.e. you can simulate one model in another. Go can somewhat emulate Actor model using concurrency control structures and buffered channels with non-blocking send to emulate mailboxes.