Seven Concurrency Models in Seven Weeks

Author:  Paul Butcher 
Publisher: Pragmatic Programmers
Pages: 300
ISBN: 978-1937785659
Print:1937785653
Kindle:B00MH6EMN6
Audience: Experienced programmers
Rating: 4.5
Reviewer: Mike James

The subtitle tells it all "When Threads Unravel".

Concurrency is not an easy topic. Just when you think you understand it there seems to be another way to make a mess of it just waiting to be discovered.

This isn't a traditional academic book on the subject. It is an attempt to explain concurrency in a reasonably practical way. Don't expect the book to give you definitive answers it is more about making you aware of the problems and how to avoid them. 

The introduction explains what concurrency is and contrasts the idea os asynchronous and parallel execution. It also introduces the seven models to be examined in the the book: 

  • Thread and locks
  • Functional programming
  • The Clojure Way - separating identity and state
  • Actors
  • Communicating Sequential Processes (CSP)
  • Data parallelism
  • Lambda Architecture

Chapter 2 starts with on this list with threads and locks and it is a potted introduction to the basic approach to concurrency. It is some of what you would learn in a computer science course on the topic including the well known dining philosopher's problem, deadlock and all manner of locking schemes. The discussion is good and so are the examples. Occasionally the explanations miss some of the questions that every beginner has such as why do we lock on this so often and how do you organize which objects to use as locks. 

Chapter 3 is a look at functional programming and it is the first of a number of chapters on Clojure, a Lisp-like language that runs on the JVM. This is by no means a Clojure book, but you do have to read and follow the examples given in the language. It is used to make a point. After a good explanation of why functional programming is a good idea and how it makes concurrency easy because of immutable data structures and pure functions we don't really get to grips with why this is. Instead we learn about how to implement functional parallelism with a map reduce type approach. The next chapter follows on with a deeper look at Clojure and the Agents/Transactional memory approach.   

Chapter 5 looks at another approach to concurrency this time Actors in Elixir, which isn't the most commonly used language in the world but is difficult to beat when it comes to this job.

Chapter 6 uses Go as an example of communicating sequential processes, i.e. Go channels.

Chapter 7 introduces the use of the GPU as a general purpose parallel computer. This is just deep enough for you to start to understand. If you want to know more you will need another book on OpenCL.

The final chapter is about the Lambda architecture which is essentially Hadoop and map reduce.  

Conclusion

This is an easy to read book on a difficult topic and for this it is welcome. It is a good introduction to seven approaches to the problem, or rather seven aspects of the problem. It isn't a book about Clojure, which you might conclude from looking at the chapter headings, but it isn't a book about pure concurrency either  - different languages are used to illustrate the approaches.

Personally I would have liked more on the basic approach using locks and something on lock free algorithms. It also doesn't cover the problem of asynchronous programming and there is no mention or promises or async and await. Don't expect it to teach you all of the techniques in, say  Java concurrency or how to best use locks, but it will give you a reasonable overview of the topic. 

This is a good book if you want to read around the topic rather than solve a specific problem. For this it is highly recommended. 

 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

Banner


Python Programming and Visualization for Scientists 2nd Ed

Author: Alex DeCaria and Grant Petty
Publisher: Sundog Publishing
Pages: 372
ISBN: 978-0972903356
Print: 0972903356
Audience: Scientists wanting to use Python
Rating: 2
Reviewer: Mike James
Visualization - a difficult topic and difficult to see how to explain the ideas in a book.



Racket Programming the Fun Way

Author: James W. Stelly
Publisher: No Starch Press
Date: January 2021
Pages: 360
ISBN: 978-1718500822
Print: 1718500823
Kindle: B085BW4J16
Audience: Developers interested in Racket
Rating: 4
Reviewer: Mike James
If you have ever wanted to Lisp then try Racket.


More Reviews

Last Updated ( Friday, 04 November 2016 )