3 ms·
> They are a hell to debug, as they are unnamed. And they're anonymous That was one odd thing that stood out to me about Go. I am coming from Erlang so a proce
by rdtsc 2y ago
> They are a hell to debug, as they are unnamed. And they're anonymous
That was one odd thing that stood out to me about Go. I am coming from Erlang so a process having process ID we can keep track of, terminate it, trace, etc, is fundamental to be able to reason about and operate a system. Advertising that they can handle millions of lightweight goroutines but then having no obvious way to identify them, and monitor their lifetimes is kind of strange.
On the lower level, I sort of understand why they did it: they focused on typed channels. So they can have multiple channels of different types potentially talking to the same goroutine. Now, having both named goroutines and channels would be more complicated, and they tried to keep things "simple". Erlang's processes on the other hand, have implicit mailboxes, there is no "mailbox1" and "mailbox2" there is only one, but it's also easier there because there is no static typing. There things are simple because only processes have identities but not mailboxes.
- jimbokun 2y agoSo Erlang unifies both the gorountine and the channel into a single construct with an identifier?
- rdtsc 2y agoWe could say that yeah. It's not unlike an os process with a pid. You can monitor the process using a pid, you can kill it, you can trace it, gets it stack trace etc. But unlike an OS process it also has a mailbox associated with it, so you can send it message and it can receive and pattern match on them.