C
C
Christina2017-01-30 16:36:02
Scala
Christina, 2017-01-30 16:36:02

What books to read on parallel programming in Scala?

I would like to know what literature you recommend for a deeper study of parallel programming in Scala.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nirvimel, 2017-01-30
@nirvimel

In parallel, programming is mostly about runtime, not the language itself.
Therefore, you can take all the same literature as for parallel programming in Java (and there is enough such literature). The principles are the same there, and the libraries mostly overlap. Another language does not interfere with using a common runtime. The only difference is that in Scala, similar code can end up looking much prettier (if you think like Scala when writing).
Subsequently, it is worth moving on to studying the documentation for specific Skalavian parallel libraries/frameworks (Akka and others). At a more advanced level, reading the sources of the standard and third-party libraries will provide much more information in a shorter time, and reading books (whose authors just let the code they read through their heads) will seem like a waste of their time.
Recipe for learning (one of the possible): If you start from the very basics, then the corresponding chapter (about concurrency) from Bruce Eckel's book will do. It gives a very good introduction to the topic, reveals the problems relevant to this area and shows the main ways to solve them.
Next, you should choose a more specific direction. Within the framework of the topic of parallel computing, there are several different approaches (mixing them in one project is not only pointless, but also dangerous).
1. Classic approach based on threads and resource locks.
1A. Variation (1), where non-blocking queues are used instead of explicit locks.
2. An approach based on the widespread use of Promise/Future.
3. Actors (typed and untyped (for some reason these are becoming more popular)).
4. STM.
After choosing an approach to solving parallel computing, you should choose a specific tool (library) and delve into the study of its official documentation and any examples found on the Web. At a more advanced level, it will be possible to move on to reading the source code and third-party literature will no longer be needed.
UPD: After all, there is a special book on Scala Concurrecy . I didn't read it. But judging by the table of contents, all the main topics are revealed there.

D
denisftw, 2017-02-09
@denisftw

Depends on goals. If you need to get a theoretical overview of all possible approaches, then yes, you can look at the book "Learning Concurrent Programming in Scala" written by Alexander Prokopets from EPFL. If you are interested in more practical things, then this is of course superfluous.
By and large, the main abstraction for organizing asynchronous processing in Scala is Future. They are typed, they are composable, they are supported by almost all mainstream libraries, they are described in almost any book on Scala 2.10+. Their main disadvantage is that they are not lazy by design, which is why they start executing immediately and require an ExecutionContext for most operations. The Typelevel party has many alternatives that do not have this drawback - ScalaZ Task, FS2 Task and finally Monix Task (by the way, very good documentation - https://monix.io/docs/2x/eval/task.html).
Akka, as such, of course, is not an alternative to Futures - and should be used in a very limited way: Actors are not typed, not composable. Their main use case is long-lived stateful processes. Almost no one uses STM and locks in Scala.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question