Tutorials about the Scala programming language.

Strategic Scala Style: The Principle of Least Power alvin March 1, 2017 - 5:52pm

Li Haoyi has a nice blog post titled, Strategic Scala Style: Principle of Least Power.

A simple Akka (actors) remote example alvin February 28, 2017 - 8:55pm

While doing some crazy things with SARAH, I realized that the best way to solve a particular problem was to use remote Akka actors. I haven’t had the opportunity to work with Akka much since finishing the Scala Cookbook, so I dug around trying to find a simple Akka remote “Hello, world” example. Unable to find a good one, I read some stuff, and created it myself.

Researching the use of an IO Monad in Scala alvin February 26, 2017 - 7:44pm

As I was researching who might be using an “IO Monad” in Scala, I found this quote from Martin Odersky in the Google Group titled “scala-debate”:

“The IO monad was a neat trick for combining side effects with lazy evaluation ... there is only one lazily evaluated language in wide usage today and even its creators have said that laziness was probably a mistake. Strict languages don’t need the IO monad, and generally don’t have it, even though they could. Bob Harper’s posts in his ‘existential type’ series are a good explanation on why not.”

Here’s a link to Bob Harper’s The Point of Laziness article.

Starting to write an immutable singly-linked list in Scala

For some examples in my new book on functional programming in Scala I needed to create a collection class of some sort. Conceptually an immutable, singly-linked list is relatively easy to grok, so I decided to create my own Scala list from scratch. This tutorial shows how I did that.

Back to top

Background: What is a Cons cell?

The first time I learned about linked lists was in a language named Lisp. In Lisp, a linked list is created as a series of “Cons” cells. A cons cell is simple, it contains only two things: