3 ms·
Funny timing for me -- last Friday I rewrote some code from channels to traditional sync primitives (to the code's improvement), and I was musing in my head tha
by dilap 11y ago
Funny timing for me -- last Friday I rewrote some code from channels to traditional sync primitives (to the code's improvement), and I was musing in my head that while everyone always says "don't communicate by sharing, share by communicating, yada yada," it doesn't seem to work out that way in practice.
I think the article is well-written, and clearly comes from a place of deep experience and understanding. Good stuff.
- gort 11y agoI had a similar experience in the opposite direction. Two weeks ago I moved some code from a mutex-based design (including a map of string to mutex, which itself needed to be behind a mutex) to channels, and I love it, though the result seemed about 10% slower. I guess the message is: everything has its place; don't make a straight-jacket for yourself.
- dilap 11y agoNo doubt it's quite easy to go down ratholes using mutexes and whatnot. It's a very low-level way of synchronizing. The OPs critques of the specific design of channels as implemented by Go seem on-point to me.