3 ms·
The actor model in Go looks like this: type actor struct { c chan message } func (a *actor) foo(...) { a.c <- message{...}
by sagichmal 8y ago
The actor model in Go looks like this:
type actor struct {
c chan message
}
func (a *actor) foo(...) {
a.c <- message{...}
}
func (a *actor) run(...) {
for {
select {
case msg := <-a.c:
a.process(msg)
// ...
}
}
}
This is perfectly idiomatic Go for a large class of problems. Therefore it's not correct to say that "Go is clearly not designed with [actors] in mind."
To be fair, it is probably correct to say that Go provides CSP natively, and leaves actors to be implemented by the programmer, and that this "hierarchy", that CSP makes a better foundation for actors than vice-versa, is an opinion codified by the language.