News for hackers. Stuff that matters.
Re:Sane Concurrency with Go by xkarga00 on Wednesday March 12, 2014 @10:07PM (#7389706)
Using mutexes isn't considered as idiomatic Go code
Re:Sane Concurrency with Go by zaphar on Thursday March 13, 2014 @12:23AM (#7390035)
Mutexes are absolutely idiomatic Go code. In fact the Core developers on the ML will often suggest them as a simplification over goroutines for synchronizing access to a shared resource. I'm not sure where you get the idea that they aren't idiomatic.
Re:Sane Concurrency with Go by xkarga00 on Thursday March 13, 2014 @04:22AM (#7390600)
Probably by making the mistake to read the Effective Go.

http://golang.org/doc/effective_go.html#concurrency

"Do not communicate by sharing memory; instead, share memory by communicating.

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. "

Re:Sane Concurrency with Go by amix on Thursday March 13, 2014 @06:09AM (#7390893)
I don't really think what I suggest goes against the article you link to. It basically says: use channels when appropriate, but sometimes the best approach is to use locks.

E.g. An bank account is shared state (similar to a reference count) and the best approach is to put a mutex around it instead of fighting with channel synchronization.

Re:Sane Concurrency with Go by xkarga00 on Thursday March 13, 2014 @07:15AM (#7391085)
There are no implications here, it's stated pretty explicitly:

"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."

There is a difference between what someone with a background from other mainstream programming languages might think would be the best approach to locking (mutexes) and the idiomatic Go approach (unbuffered channels).

Re:Sane Concurrency with Go by nkozyra on Wednesday March 12, 2014 @10:11PM (#7389718)
Well anything other than direct channel <-> goroutine is not considered idiomatic.