by jstewartmobile · 7y ago · 0 comments
Most encounters I've had with "message passing"--whether it was AJAX, Win32 PostMessage, or grade school--have been non-blocking. Go channels block.
edit: Here's a pretty good write-up from 2016 on why channels are an anti-pattern:
https://www.jtolio.com/2016/03/go-channels-are-bad-and-you-s...
Go tried CSP in the beginning but in CSP the 'sequential process' preempts only on blocking (IO) or until finished.
Also message passing is just that. You can't reach out and modify a message after you have posted it, IRL. This means messages are 'safe' to use concurrently since they are copies. That, in conjuction with strict CSP ssemantics (processes always run to completion with no preemptive cooperation) gets you 'safe concurrency' at the price of performance and at scale 'reasoning' about what is happening.
So, the practical decisions were (a) honors system message passing via references, (b) preemption at IO and elsewhere, and (c) introduction of mutex, etc. to fall back to [more performant] 'light weight threads' and 'locks' paradigm.
I would say though that go channels have not turned out to be as useful as I thought they would be. I dont find myself using them that much. But maybe it's just my style or the type of stuff I am writing.
No, async/await is typically stackless, while goroutines have stacks. That's a significant difference.
With something like pipes or sockets, there are timeouts and saner handling of breakages. With Go channels, one false move, and you've got a panic or an infinite wait.
I like Go, just not a big fan of channels.