Scala, Java, Unix, MacOS tutorials (page 1)

As you can tell from one look at the Scaladoc for the collections classes, Scala has a powerful type system. However, unless you’re the creator of a library, you can go a long way in Scala without having to go too far down into the depths of Scala types. But once you start creating libraries for other users, you will need to learn them. This chapter provides recipes for the most common type-related problems you’ll encounter.

Scala’s type system uses a set of symbols to express different generic type concepts, including the concepts of bounds, variance, and constraints.

A friend posted this quote on Facebook recently: “Speak to people in a way that if they died the next day, you’d be satisfied with the last thing you said to them.”

It made me think that I was happy that Lori and I had a good relationship through Facebook, and that the last time I talked to Ben, he was showing me photos from a cruise that he took, and giving me advice if I should ever go on one.

As this image shows, as of September 14, 2021, the Scala Cookbook is still a #1 new release in both the object-oriented programming (OOP) and functional programming (FP) categories. Because these are the two main computer programming categories, and the Cookbook has been a #1 new release for a month now, it was suggested that it might be a Great 2021 Geek Gift Idea. I can’t argue with that. :)

(The image here shows two browser windows, with the OOP page on the right overlapping the FP page on the left. The images were taken on September 14, 2021.)

Scala Cookbook, a great geek gift idea

“Don’t cling to a mistake just because you spent a lot of time making it.”

This is one view of Mother Nature pouncing on Boulder, Colorado. (Boulder and the Rocky Mountains are under that blanket of clouds.)

Boulder, Colorado flooding, 9/12/2013

Thanks to Scala being both an object-oriented programming language and a functional programming language, here on the last day of August, 2021, the Scala Cookbook (for Scala 3) is the #1 new release in both the OOP and FP categories.

UPDATE: The book is still #1 in both categories on September 7, 2021 — one month after the Kindle release.

(In the image shown, the Amazon OOP category is on the left, and the FP category is on the right.)

Scala Cookbook: #1 new release in OOP and FP

I can’t find the exact story or specific details, but it goes something like this ... after his initial work with Maharaji in India, Ram Dass came back to the U.S. and lectured on spirituality. As he says it, “I was supposed to be a spiritual teacher with no attachments, but the reality is that wherever I went, I had these nine boxes of things that were of sentimental value to me.” So he’d go from city to city lecturing about how to have no attachments, and all the time he was lugging these nine boxes around behind him.

One day he realized that he really needed to give up his attachments to those things, so he did his best to give everything away, but at the end he still had three boxes remaining. “I’m sorry, Maharaji,” he said, “that’s all I can do for now, this is killing me.”

“That was a few years ago,” Ram Dass said. “Now I have thirteen boxes.”


I’ve gotten back into creating faux paintings again recently, and this is one of Silas in The Da Vinci Code.

(“Is that a dagger or a crucifix I see?” ~ Blood of Eden, by Peter Gabriel)

Faux painting of Silas, from The Da Vinci Code

While at a doctor’s office, a nurse asked me what makes Scala special.

I said, “You know how some spoken languages sound beautiful, like Italian or French? In the same way, some programming languages look beautiful, like Scala 3. So we use other languages when we’re forced to, but we use beautiful languages because we want to.”

As a quick note to self, I just used these contents in a Scala/sbt build.sbt file when working with the GraalVM native-image command (and sbt plugin). I share these here so I can remember how to specify command-line options for the native-image plugin in the build.sbt file:

lazy val sbtmkdirs = (project in file("."))
        name := "http_client",
        version := "0.1",
        scalaVersion := "3.0.1",
        Compile / mainClass := Some("foo.HttpClient"),
        // these are the native-image options i used
        // to work with HTTP and HTTPS (though I don’t know
        // if they are all needed)
        nativeImageOptions ++=

scalacOptions ++= Seq(

If you’re finding Akka Typed hard to learn, fear not, it took me almost two days to get the simplest of their Scala examples working. And I had already written the original Scala Cookbook, and already knew how to use Akka Classic!

As a remedy to this problem, I wrote about how to use Akka Typed in the 2021 version of the Scala Cookbook. In the book I show some of the simplest possible Akka Typed examples, so you won’t have to waste two days of your life trying to get a simple example running.

Here in August and September, 2021, the Scala Cookbook is a best-selling new programming book in both the OOP and FP categories. And as I found out yesterday, a great thing about writing for O’Reilly is that if you write a book for them, they’ll send you a bunch of free copies, even when the book is almost 800 pages long. Makes for a great unboxing experience!

Scala Cookbook unboxing experience (2021 best-selling new release)

Personal Diary, September 2, 2010, Wasilla, Alaska:

I bought a fig at the grocery store today. Turns out they’re about the size of a Hershey’s Kiss. The checkout person just looked at me. “One fig? You want to buy one fig?”

“Yes, just one. I want to see what they taste like.”

She put the fig in the bag without weighing it. “I’m pretty sure I can give you one fig without charging you for it,” she said.

If I had a flower for every time I thought of you, I could walk in my garden forever.

One of the things I love about Peter Gabriel’s music is how brutally honest his lyrics are. Sure, there’s imagery and metaphor and other things that make music great, but like these lyrics from Washing of the Water, the lyrics are just raw and emotive:

’til the washing of the water
Make it all alright
Let your waters reach me
Like she reached me tonight

Letting go, it’s so hard
The way it’s hurting now
To get this love untied
So tough to stay with thing
’cause if I follow through
I face what I denied
I get those hooks out of me
And I take out the hooks that I sunk deep in your side
Kill that fear with emptiness
Loneliness I hide

River, oh river, river running deep
Bring me something that will let me get to sleep
In the washing of the water will you take it all away
Bring me something to take this pain away

I believe it was Stevie Nicks who sang about the Cooler of Love, and wouldn’t we all like to drown there.

The Cooler of Love, Longmont, Colorado

I’m happy to report that the Scala Cookbook for Scala 3 — a.k.a., the Scala 3 Cookbook — is now the #1 new release in Amazon’s functional programming category, as of late August, 2021. This comes on the heels of already being the #1 new OOP book.

Scala Cookbook: #1 new release in functional programming

As a quick note today, in this post I’ll share some examples of the Scala map method as it works on sequences like the List, Vector, and Seq classes.

map == transform

Basically you can think of map as meaning transform: it lets you transform one collection into another. For instance, these examples in the Scala REPL show how to transform a list of strings into a list of integers, where the integers correspond to the length of each string:

It turns out he had a little magic in him: With his overabundance of unconditional love, he could change people. I know, because he changed me.

~ from this story about Zeus

I was laying in bed last night, waiting to fall asleep, and the power went out. As I laid there thinking about how cold it would get, a gray telephone we had many years ago began ringing in the closet. I wondered what it was doing in there.

Instantly the scenery changed and I flashed back to an event I didn’t know about twelve years ago. As I observed it, it made me sad.

Then I kept going back in time, first to one event and then another.