Chapter 1

Concurrency Everywhere

The actor model of concurrency was born of a practical need: When Carl Hewitt and his team at MIT first described actors in the 1970s, computers were relatively slow.[1] While developers could already divide up work among several computers and compute in parallel, Hewitt's team wanted a model that would not only simplify building such concurrent systems, but would also let them reason about concurrent programs in general. Such reasoning, Hewitt and his team believed, would allow developers to be more certain that their concurrent programs worked as intended.

Although actor-based concurrency has been an important concept ever since, it is only now gaining widespread acceptance. That is in part because until recently no widely used programming language offered first-class support for actors. An effective actors implementation places a great burden on a host language, and few mainstream languages were up to the task. Scala rises to that challenge, and offers full-featured implementations of actor-based concurrency on the Java virtual machine (JVM). Because Scala code seamlessly interoperates with code and libraries written in Java, and other languages for the JVM, Scala-based actors offer an exciting and practical way to build scalable and reliable concurrent programs. This book introduces the two most important actor implementations for Scala: the scala.actors package of the standard library[2] and the actors package of the Akka project.[3]

Like many powerful concepts, the actor model can be understood and used on several levels. On one level, actor-based programming provides an easy way to exchange messages between independently running threads or processes. On another level, actors make concurrent programming generally simpler, because actors let developers focus on high-level concurrency abstractions and shield programmers from intricacies that can easily lead to errors. On an even broader level, actors are about building reliable programs in a world where concurrency is the norm, not the exception—a world that is fast approaching.

This book aims to explain actor-based programming with Scala on all those levels. Before diving into the details of Scala actors, it helps to take a step back and place actors in the context of other approaches to concurrent programming, some of which may already be familiar to you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset