Tutorials about the Scala programming language.

Hello, Scala is now Scala Book alvin October 14, 2019 - 5:09pm

One small step for me, and I don’t know if it will help mankind at all. But Hello, Scala is now called Scala Book, and you can find it here on

An example of Union Types in Scala 3 (Dotty) alvin October 10, 2019 - 9:33am

Here’s an example of Union Types in Scala 3 (Dotty). This image comes from this Martin Odersky video.

A quiet, attractive new programming language alvin September 29, 2019 - 8:00pm

Here’s some source code that demonstrates a quiet, concise, and attractive new programming language I’d enjoy using:

Scala 3 (Dotty), September 30, 2019

Scala 3: No parentheses in control structures alvin September 28, 2019 - 7:55am

When I originally saw the first image, I thought it was a “This would be nice in Scala 3 (Dotty)” idea. But then I found the “No parentheses in control structures” pull request shown in the second image. Here’s a link to that pull request.

How to search for multiple regex patterns in many files with `ffx`

I recently created a command I named ffx that lets you search your filesystem for files that contain multiple strings or regular expressions. This post describes and demonstrates its capabilities. (There’s a little video down below if you want to see how it works before reading about it.)

Think of the Scala collections’ map method as “transform” alvin September 18, 2019 - 1:00pm

I’ve written this before, but when I saw this “pseudocode to Scala code” example in the book Functional Thinking, I thought it was worth mentioning again: If you have trouble grokking the Scala map method, think of it as being named transform instead. It transforms an input collection to an output collection, based on the algorithm you supply.

For those coming from the OOP world, I think “transform” is a better word because it is more meaningful, at least initially.

ADTs is Scala 2 and Scala 3 alvin September 11, 2019 - 8:10pm

I’ll write about this a little more when I’m awake, but here’s a little look at ADTs implemented in Scala 2 (with traits and case objects) and Scala 3 enums.

FP is not about not having side effects at all alvin September 11, 2019 - 10:54am

“I though it was obvious, but apparently it's not. FP is not about not having side effects at all, otherwise it would be useless. It's just about deferring them for as long as possible, that's all.”

~ Alessandro Lacava, in this tweet

A Scala “file find” utility

I wanted some specific features in a “find” utility, and when I couldn’t figure out how to get them with combinations of find, awk, and other Unix commands, I wrote what I wanted in Scala. Those features are (a) showing matching filenames, (b) showing the line that matches my search pattern, and underlining the pattern in the output, (c) showing the line numbers of the matches, and (d) showing an optional number of lines from the file before and after each match.