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

My 700+ page book, Functional Programming, Simplified — 4.5-star rated on Amazon, their 6th-best selling book on functional programming, and 5-star rated on — is currently on sale in three formats (prices shown in USD):

PDF Format
$15 (sale!) on

PDF version of Functional Programming, Simplified

Paperback Book
Now $34.99 on Amazon

Print version of Functional Programming, Simplified

Kindle eBook
$14.99 on Amazon

Kindle version of Functional Programming, Simplified

When you get started with functional programming (FP) a common question you’ll have is, “What is an effect in functional programming?” You’ll hear advanced FPers use the words effects and effectful, but it can be hard to find a definition of what these terms mean.

Effects are related to monads (but don’t worry)

A first step in the process of understanding effects is to say that they’re related to monads, so you have to know just a wee bit about monads to understand effects.

As I wrote in my book, Functional Programming, Simplified, a slight simplification is to say that in Scala, a monad is any class that implements the map and flatMap methods. Because of the way Scala for-expressions work, implementing those two methods lets instances of that class be chained together in for-expressions (i.e., for/yield expressions).

I drove through Chicago recently and with my crappy old phone’s camera I got this photo of the pink and orange Moon rising over Greater Chicagoland. It was a clear night and the Moon was visible for the entire drive.

Pink/orange Moon rising over Greater Chicagoland

I moved to Colorado after Josh McDaniels was fired by the Broncos, and to say the least, from what I’ve heard on the local radio, he sounds like a completely different coach with the Raiders (per this article):

“One of the easy things that we’ve tried to keep in mind is we’ll get the best out of everyone here if they love coming to work every day because they love who they’re working for,” said McDaniels, sitting behind his desk. “That sounds so ridiculously simple. Seriously. But it’s the truth. If the players enjoy being coached by us the way we’re coaching them, if the coaches enjoy being treated the way they’re being treated, if the scouts and the personnel department enjoy the way that [GM] Dave [Ziegler] runs the meetings and gives everybody a voice, then when they drive in here in the morning? You should see this.”

“I’d say for me that’s from being a guidance counselor, being a teacher, those experiences,” Ziegler said. “The relationship was really what you had to solidify first to make any progress, whether you’re a classroom teacher or a guidance counselor, and you’re trying to help someone through a problem.”

“They won’t trust you if you don’t,” McDaniels said.

“As a guidance counselor, you have to create it on the front end so if there is a problem down the road, you’ve already created the relationship, so you can help someone that’s having a mental health issue, or going through something else,” Ziegler continued. “The relationship has to come first.”

Summary: This page is a printf formatting cheat sheet or reference page. I originally created this cheat sheet for my own programming purposes, and then thought I would share it here.

A great thing about the printf formatting syntax is that the format specifiers you can use are very similar — if not identical — between different languages, including C, C++, Java, Perl, PHP, Ruby, Scala, and others. This means that your printf knowledge is reusable, which is a good thing.

Every once in a while when something hits you, you really remember it; it stands out in your mind as an “Aha” moment. One of those moments for me was when I saw a particular “Model/View/Controller” (MVC) diagram, and the light bulb went on. This diagram made the MVC pattern very simple, and I’ve never forgotten it.

The Model / View / Controller diagram

The diagram I’m talking about comes in two parts. The first MVC diagram shows the symbols the authors use for Model, View, and Controller objects. Here’s that diagram:

Model View Controller - symbols for MVC objects

Kotlin FAQ: How do I iterate over a Map in Kotlin?

Solution: Here’s an example that shows how to iterate over the elements in a Kotlin Map using a for loop:

val map = mapOf("a" to 1, "b" to 2, "c" to 3)

for ((k,v) in map) {
    println("value of $k is $v")

I saw the following image on this Twitter page:

and immediately became curious, “How can I create something like that Ruby %Q function in Scala, but where each line becomes a string in a list, i.e., a Seq[String]?”

“It is not the critic who counts; not the man who points out how the strong woman stumbles, or where the doer of deeds could have done them better.”

“The credit belongs to the woman who is actually in the arena, whose face is marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming; but who does actually strive to do the deeds; who knows great enthusiasms, the great devotions; who spends herself in a worthy cause; who at the best knows in the end the triumph of high achievement, and who at the worst, if she fails, at least fails while daring greatly, so that her place shall never be with those cold and timid souls who neither know victory nor defeat.”

~ “The Man in the Arena” speech by Teddy Roosevelt, with a few minor changes, which I was reminded of by this article

As a brief note to self, here’s some Laminar source code that shows how to create a div in Laminar, as well as some settings/elements in that div, as well as one way to handle a reactive button click:

In my first Laminar tutorial I showed how to set up a Scala/sbt project to use Laminar to render “static” HTML code. Then in Laminar 102: A reactive “Hello, world” example, I showed how to create a small, reactive Laminar example, that sends signals from one widget to another using observables and observers.

In my experience, the next thing you’ll need to know about Laminar is routing, i.e., how to transition from one page to another in a single-page app (SPA). Therefore, in this tutorial I’ll show how to implement that for very small applications.

In my first Laminar tutorial I showed how to set up a Scala sbt project to use Laminar, and then showed a “static” example — i.e., there were no moving parts. Please see that tutorial first if you’ve never used Laminar.

BUT, because Laminar is meant for writing reactive applications with observables and observers, this tutorial begins to show its reactive concepts.

This article contains a collection of quotes on design from former Apple designer Jonathan Ive (or “Jony Ive,” as Steve Jobs called him). As an interesting note, Mr. Ive prefers to refer to himself as a “builder” or “maker” as opposed to a designer.

For those who don’t know of him, Jonathan Ive is credited with designing almost every Apple product from 1997 until roughly 2020. Given that very long string of success, I became interested in what Mr. Ive has to say about design, and to that end, here’s a collection of Jonathan Ive design interview quotes I’ve gathered over the last few years.

This page contains a list of my favorite “mindfulness reminder” quotes. In particular these are short, concise quotes that I think work well with my “Just Be” mobile app.

Just Be is currently an app for Android users. If you haven’t seen it before, this is what the reminders/notifications look like when you receive them on an Android phone or tablet:

[toc hidden:1]

I recently started a new Scala project that uses the Scala/Scala.js Laminar library for frontend development (i.e., as a JavaScript replacement).

Laminar is a library that’s built on top of Scala.js to let you build “reactive” web applications with observables, and in this tutorial I’ll show how to create a static “Hello, world” application from scratch. Once we get past these basics, I’ll show in Part 2 of this series how to create a reactive single-page application (SPA) with Laminar.

When I first saw Scala code like this ~12 years ago, my initial thought was, “Wow, maybe I need to think about a different career”:

def race[A, B](lh: IO[A], rh: IO[B])(implicit cs: ContextShift[IO]): IO[Either[A, B]]

But in the end, as Rocky once said, it ain’t so bad. :)

Rocky: You ain’t so bad

For many years I struggled with how to combine two of my main interests, Zen and work. I have read that the Zen mind is the mind before thinking, so it seems like Zen and work must be totally unrelated; you need your mind to work. And then over time I came to understand phrases like, when working, just work.

This article contains a collection of quotes that have been helpful to me in understanding the relationship between Zen and work. Please note that I don’t wrap each quote in double quotes, and I also try to attribute each quote to the correct author/speaker. If you’re interested in how to combine Zen and work, I hope you’ll find them helpful.

At some point somebody was like, “Let’s get a mast cell — a type of white blood cell — from a bone marrow biopsy, magnify it 1,000 times, piss it off, and see what happens.”

The result? Ka-boom! It looks like a little firework went off when it released its histamine, tryptase, serotonin, superoxide, heparin, thromboxane, PGD2, PAF, and other granules.

That’s pretty much what it feels like, lol. I used to tell doctors that it felt like I had been drugged, and indeed, I was.

(Image from this research paper.)

MCAD: What an activated mast cell looks like

Over on my Valley Programming website I wrote a little User Story Mapping Example Using Facebook. Whether people currently have a Facebook account or not, at one time almost everyone did, so it makes for a good example when running a story mapping workshop. See that link for more details.

A User Story Mapping Example Using Facebook

This is an excerpt from the Scala Cookbook, 2nd Edition. This is Recipe 3.10, Using Java Collections in Scala.


You’re using Java classes in a Scala application, and those classes either return Java collections, or require Java collections in their method calls, and you need to integrate those with your use of Scala collections.


Use the extension methods of the scala.jdk.CollectionConverters object in your Scala code to make the conversions work. For example, if you have a method named getNumbers in a public Java class named JavaCollections: