What is the major difference between scala concurrency and go concurrency?

How is the scala concurrency model different from golang’s?

The question isn’t well-formed, since Scala really doesn’t have a single concurrency model. When running ScalaJVM, you’re using the JVM (Java) concurrency model; when using ScalaJS, you’re using the JavaScript engine, which is single-threaded.

So as a language, Scala doesn’t impose a single concurrency model – it depends on the platform you’re running on, and to some degree the libraries you’re using…

1 Like

Go’s memory model is based on communicating sequential processes (CSP) which was invented by Tony Hoar. It is described in detail here: PDF. There is a very good introduction into the problem domain by Robert Pike, the main creator of Go on Youtube: Concurrency Is Not Parallelism.

CSP is based on green threads which are not available on the JVM. The workaround is to implement fibers on the JVM as this has been done in Quasar and with Coroutines in Kotlin.

I won’t go into any further explanation of all that. I’m only going to drop the remark that CSP partly removes the inherent difficulty of asynchronous programming (at the expense of loosing preemptive threads due to the change to green threads). You can easily find tons of articles on the Internet about CSP, Go, Quasar, etc. To get some understanding beyond reading articles it is helpful to write some concurrent toy programs with Go.

Just in case you or anyone else is interested:

Quoting:

JC has the same expressive power as CSP (Communicating Sequential Processes) and the Actor model, but is easier to use and reason about, more high-level and more declarative. (See also Conceptual overview of concurrency.)