Actors in Scala by Philipp Haller

By Philipp Haller

Contemporary traits in machine structure make concurrency and parallelism a necessary component of effective application execution. The actor version of concurrency permits you to exhibit real-world concurrency in a ordinary method utilizing concurrent strategies that converse through asynchronous messages.

Scala is a programming language for the Java digital computer, offering first-class aid for either object-oriented and practical programming. through together with a strong actor framework in its usual library, Scala bargains a compelling method of take on concurrent programming. Scala's actors allow you to follow the actor concurrency version to the JVM, permitting real-world ideas which are effective, scalable, and strong.

Published via Artima, this is often the 1st e-book on Scala's actors, co-authored by way of the writer and lead maintainer, Philipp Haller, and Frank Sommers. beginning with the basics of the actor concurrency version, this publication deals a finished educational on sensible programming with actors in Scala. It allows you to leverage the entire energy of modern day and tomorrow's multi-core processors by means of describing either simple and complicated beneficial properties of Scala's actor framework in-depth.

Show description

Read or Download Actors in Scala PDF

Best software development books

Leadership, Teamwork, and Trust: Building a Competitive Software Capability (SEI Series in Software Engineering)

Each enterprise is a software program company, and each company can cash in on greater software program procedures   management, Teamwork, and belief discusses the severe significance of data paintings to the good fortune of recent enterprises. It explains concrete and important steps for reshaping the best way software program improvement, particularly, is carried out.

Actors in Scala

Fresh traits in machine structure make concurrency and parallelism an important aspect of effective application execution. The actor version of concurrency lets you convey real-world concurrency in a usual means utilizing concurrent approaches that speak through asynchronous messages. Scala is a programming language for the Java digital computer, delivering first-class help for either object-oriented and practical programming.

The Effective Engineer: How to Leverage Your Efforts In Software Engineering to Make a Disproportionate and Meaningful Impact

The simplest engineers — those who've risen to turn into wonderful engineers and leaders at their businesses — can produce 10 occasions the effect of different engineers, yet they are not operating 10 instances the hours.

They've internalized a approach that took me years of trial and mistake to determine. i'll percentage that approach with you — besides 1000's of actionable strategies and confirmed behavior — so that you can shortcut these years.

Introducing The potent Engineer — the one publication designed in particular for modern day software program engineers, in accordance with broad interviews with engineering leaders at best tech businesses, and filled with enormous quantities of ideas to speed up your career.

For years, I launched into a quest looking a solution to at least one question:

How do the best engineers make their efforts, their groups, and their careers extra successful?

I interviewed and picked up tales from engineering VPs, administrators, managers, and different leaders at contemporary best software program businesses: proven, family names like Google, fb, Twitter, and LinkedIn; speedily turning out to be mid-sized businesses like Dropbox, sq., field, Airbnb, and Etsy; and startups like Reddit, Stripe, Instagram, and Lyft.

These leaders shared tales concerning the most beneficial insights they have discovered and the most typical and expensive error that they have obvious engineers — occasionally themselves — make.

Extra info for Actors in Scala

Example text

To allow many actors in a JVM, you can make your actors event-based. Event-based actors are implemented as event handlers instead of as threads, and are therefore more light-weight than their thread-based cousins. Since event-based actors are not tied to Java threads, event-based actors can execute on a pool of a small number of worker threads. Typically, such a pool should contain as many worker threads as there are processor cores in the system. That maximizes parallelism while keeping the overhead of pool threads– memory consumption and context-switching–to a minimum.

Let’s find out just how lightweight they actually are by creating chains of actors of ever increasing size until the JVM runs out of memory. Moreover, we can compare that chain with thread-based actors by replacing the two r❡❛❝ts with r❡❝❡✐✈❡s. But first, how many event-based actors can we create? And, how much time does it take to create them? On a test system, a chain of one thousand actors is built and terminated in about 115 ms, while creating and destroying a chain of ten thousand actors takes about 540 ms.

A chain of two thousand threaded actors takes already over 97 seconds. With a chain of three thousand actors, the test JVM crashes with an ❥❛✈❛✳❧❛♥❣✳❖✉t❖❢▼❡♠♦r②❊rr♦r. As this simple test demonstrates, event-based actors are much more lightweight than thread-based actors. The following sections explore how to program with event-based actors effectively. Using r❡❛❝t effectively As we mentioned above, with r❡❛❝t an actor waits for a message in an event-based manner: Under the hood, instead of blocking the underlying worker thread, r❡❛❝t’s block of pattern-action pairs is registered as an eventhandler.

Download PDF sample

Rated 4.40 of 5 – based on 35 votes