3 ms·
My point is that you can program with the actor model in Go, if you want to.
by sagichmal 8y ago
My point is that you can program with the actor model in Go, if you want to.
- int_19h 8y agoYou can program with it in C, if you want to. But Go is clearly not designed with that in mind. It's a language that is very opinionated about how concurrency should work. And so whether it's a good opinion or a bad opinion becomes very important.
- sagichmal 8y agoThe 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.