Sane Concurrency with Go
When we implemented the Go and Erlang lightweight-thread approach for the JVM in Quasar[1], we quickly realized that CSP/actors, while going a long way towards sane concurrency, are not sufficient. Every application eventually needs some shared mutable state (even if it's implemented at the database layer). One approach is to have a single fiber (or goroutine) in charge of managing state (Clojure does that with agents), but that doesn't scale for multiple writers. Neither does a global lock over the entire data store.<p>Good concurrent data structures that allow multiple concurrent writers are necessary. Java has some good basic ones like ConcurrentHashMap, ConcurrentSkipListMap, and ConcurrentLinkedQueue. Clojure takes that a step further with transactional refs. For more interesting kinds of data it's better to have a good in-memory transactional database.<p>So for truly "sane concurrency" you need both lightweight threads with CSP and/or actors, <i>plus</i> a transactional, concurrent (preferably in-memory) data store[2].<p>[1]: <a href="https://github.com/puniverse/quasar" rel="nofollow">https://github.com/puniverse/quasar</a><p>[2]: <a href="http://blog.paralleluniverse.co/2013/10/16/spaceships2/" rel="nofollow">http://blog.paralleluniverse.co/2013/10/16/spaceships2/</a>