Hacker News new | ask | show | jobs
by somekyle 1664 days ago
Yes, overapplying directional advice is a problem, and channels aren't always the right choice, but mutexes/cond vars/atomics have always been part of Go and they've always been listed as viable options, just not usually the best choice for high level coordination. To quote the go1 Effective Go on channel-based interaction:

  This approach can be taken too far.  Reference counts may be best done
  by putting a mutex around an integer variable, for instance.  
  But as a high-level approach, using channels to control access makes it easier
  to write clear, correct programs.
I'm sure somebody has been banging a "Go programs should never use mutexes" drum, but it hasn't ever been the position of the Go team that channels are a panacea or that mutexes _shouldn't_ be used, as far as I've ever seen.
1 comments

Agreed. I've been writing Go since like 2011 and even when I started there was plenty of emphasis on channels as just one of the options along with mutexes and a sense that channels were easier to make correct, but mutexes were easier to make efficient. If someone else got the impression that channels were pushed exclusively, I guess they were watching different talks and reading different documentation than I was.