concurrent

Joe Armstrong: Grow software apps by adding small communicating objects

We should grow things (software applications) by adding more small communicating objects, rather than making larger and larger non-communicating objects.

Concentrating on the communication provides a higher level of abstraction than concentrating on the function APIs used within the system. Black-box equivalence says that two systems are equivalent if they cannot be distinguished by observing their communication patterns. Two black-boxes are equivalent if they have identical input/output behavior.

When we connect black boxes together we don't care what programming languages have been used inside the black boxes, we don't care how the code inside the black boxes has been organized, we just have to obey the communication protocols.

Erlang programs are the exception. Erlang programs are intentionally structured as communicating processes — they are the ultimate micro-services.

Large Erlang applications have a flat “bus like” structure. They are structured as independent parallel applications hanging off a common communication bus. This leads to architectures that are easy to understand and debug and collaborations which are easy to program.

~ From this post by Joe Armstrong, author of the book Programming Erlang: Software for a Concurrent World

How to create a Twitter client in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 15.10, “How to create a Twitter client in Scala.”

Problem

You want to create a client to connect to Twitter to access the information you want, such as showing timelines and trends.

Examples of how to use parallel collections in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 13.12, “Examples of how to use parallel collections in Scala.”

Back to top

Problem

You want to improve the performance of algorithms by using parallel collections.

Back to top

Solution

When creating a collection, use one of the Scala’s parallel collection classes, or convert an existing collection to a parallel collection. In either case, test your algorithm to make sure you see the benefit you’re expecting.

Table of Contents

  1. Problem
  2. Solution
Back to top

One way that functional programming helps with concurrency

I’ve read a lot of irrational claims about how functional programming helps with concurrency, but if a compiler can do what this says, at least it’s a clear, rational example of how FP can help with concurrency. It’s taken from an article titled, Functional programming for the rest of us.

On the Scala Future, and semantics

In programming, semantics can be important. While in many cases I don’t care too much how developers name classes and variables, in some cases monikers can cause problems. (Perhaps even in that sentence.)

A complete Scala `Future` example from the Scala Cookbook

There are a number of ways to work with Scala Futures, and I provide examples of those approaches in the Scala Cookbook.

If you’re new to Futures, a fun exercise is to try to determine what happens in your code when you use a certain technique. For instance, when you look at the following Scala source code, what do you think it will print?