logoalt Hacker News

surajrmalyesterday at 2:47 PM1 replyview on HN

It does matter. Using channels makes control flow much more difficult to understand, but allows you to avoid wrapping everything in its own mutex (or RefCell) and local reasoning is easier to understand. There is also a difference in latency and cpu utilization, both of which still matter in io bound workloads. I honestly don't think it's one or the other but optimal usage is a mix of both depending on specifics of the use case. Channels are great for things that you want to be decoupled from each other but it needs to hit a certain level of abstraction/complexity before it's worth it.

Even folks who write modern go try to avoid overusing channels. It's quite common to see go codebases with few or no channels.


Replies

thranceyesterday at 8:22 PM

I meant, when it comes to choosing between threads or async/await, it doesn't matter if you use channels or something else. Both can be used with them. My original comment wasn't very clear it seems.

Of course it matters what synchronization primitives you choose, for the reasons you gave.