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

This weekend I just released the shiny new paperback version of Learn Functional Programming The Fast Way!. And for the first 48 hours — until roughly the end of March 28, 2023 — you can buy it for half-price, here on

Learn Functional Programming The Fast Way! (paperback)

NOTE: This is a chapter from my book, Learn Scala 3 The Fast Way. Due to a mistake, this lesson was not included in the book.

When you write functions, things can go wrong. In other languages you might throw exceptions or return null values, but in Scala you don’t do those things. (Technically you can, but other people won’t be happy with your code.)

Instead what we do is work with error-handling data types. To demonstrate this I’ll create a function to convert a String to an Int.

I decided to rename my book, Learn Functional Programming Without Fear to Learn Functional Programming The Fast Way! because (a) I think it’s more reflective of today’s world, and (b) it’s consistent with my other book, Learn Scala 3 The Fast Way!.

You can currently find the PDF version of Learn Functional Programming The Fast Way! at this URL.

Learn Functional Programming The Fast Way! (new book cover)

I’m currently updating my best-selling book, Functional Programming, Simplified, to cover Scala 3 and other technologies like ZIO and Cats Effect, and when that’s done, this will be the landing page for that book.

Until then, you can find the PDF for the new book that I’m creating here:

And you can find the Scala 2 version of the book here:

I’ll update this page as I have more information.

As I continue my quest to learn about Ram Dass and Maya (illusion), I also had a very hard time finding any quotes about Maharaj-ji and Maya, and after sifting through about 1,000 pages of books I finally found this Maharaj-ji quote:

“All is God’s will, but Maya prevents you from knowing it’s all God’s will.”

If you’re interested in this, you can find this quote and a little bit more on page 326 of the book, Miracle of Love.

October, 2022 Update: I also just found the following quotes in an out-of-print book about Maharaj-ji:

  • “You see others trapped by maya (illusion).”
  • “This temple and whatever is seen by the human eye are illusion.”
  • “Delusion makes everything look real.”

In that first quote the “(illusion)” part was in the book, I didn’t add that.

(This is a recounting of a dream from October 1, 2016.)

We were playing at our camp when my older brother — who was standing on higher ground than I — saw something in the distance. He stood upright, then perfectly still. After a few moments he turned to me in a look of panic I had never seen before, pointed in a direction opposite from where he was looking, and screamed, “Run! Run!” I was startled at his behavior but I knew that something was very wrong, so I ran. And I ran.

I ran as fast as I could, weaving through the brush and constantly changing my course as I was chased by a white man on a dark horse. I thought I might be close to safety when I darted through some bushes, but I ran right into a creek that was too wide to jump across. As I paused for a moment to decide how to continue, the white man shot me in the back.

In intense pain and sudden shock, I stumbled forward into the creek, bent over with one hand in the creek. As I attempted to stand up and regain my balance, I was shot in the back again. This time my body flew forward towards the opposite side of the creek. I tried to control my fall but could not, and my torso slammed against the land. The right side of my face was pressed against the ground, my eyes still open. My right arm was trapped under my body, my left arm was somewhere down my left side. My legs lay in the creek’s water.

Lately as I’ve been writing and editing Functional Programming, Simplified: Updated for Scala 3: Could Functional Programming be called Algebraic Programming?

Yes, FP is about pure functions, HOFs, and functions as values, but it’s also about domain modeling (ADTs), immutable variables (algebraic) and immutable data, errors as values, and EOP (expressions as equations).

Other notes:

  • Functional programmers also use the term “blueprint” a lot, so that’s another possible name.
  • To be clear, I’m not calling for a name change or anything like that, just observing that Algebraic Programming may be a more accurate name.

I hope that my new book, Learn Functional Programming Without Fear, is the easiest and simplest way to learn functional programming (FP). I didn’t initially intend for it to be an FP book, but as I was writing about pure functions, immutable (algebraic) variables, immutable data structures, and functional error-handling, I realized that these were the first four essential stepping stones to help you transition from OOP to FP, and to Scala/FP libraries like ZIO and Cats Effect.

Initially I was planning to write a book titled something like “Thinking with Types” or “Solving Problems with Pure Functions,” but once I realized where it was going, I decided to create a new functional programming book that’s much shorted than my own, Functional Programming, Simplified book.

Some quotes from Sean Payton, new head coach of the Denver Broncos, that relate to business as well as football:

“Discipline, toughness, football makeup and character are going to be really important for who is a Denver Bronco. I use this story and it’s a compliment. When I got hired in New Orleans in 2006, we just had to look at New England if we really wanted to see what the standard was. If we were making pizzas and there’s a line around the block in front of their pizza parlor, then we might want to know what they’re putting in their crust or their sauce.”

Related to the Patriots and Bill Belichick: “We studied closely how important intelligence was along with communication and makeup. That served us well later. There is an element of discipline, and there is an element of toughness. Look, it’s not for everyone. It’s not for everyone, but that’s the approach we’ll take.”

“Long, uninterrupted, alert practice is the firm foundation for restraining the fluctuations of the consciousness.”

~ Patanjali (via Iyengar)

If you like my books and want to earn a little extra income, I just started using the Gumroad “affiliates” program. Just sign up with Gumroad, link to one or more books, then hopefully make some sales and earn a little extra money.

I’m starting with a 30% commission, so if you sell a $10 book like Learn Scala 3 The Fast Way! you’ll earn $3, and if you sell a $20 book like Functional Programming, Simplified: Updated for Scala 3, you’ll earn $6 (USD).

If you’re interested, start the process here on You’ll also want to read their help page for Affiliates.

Become an affiliate for Alvin Alexander’s books

Here are two favorite quotes from Anandamayi Ma. I think almost all of this comes via Ram Dass, but at the moment I can’t remember what book I saw this in. So I assume that Ram Dass or one of his assistants spoke, wrote, or compiled almost all of the following, and I’ll link to one of his books once I can confirm this.

I’ve been slowly working on a series of new Scala programming books, and today I’m proud to announce the first of these:

Learn Scala 3 The Fast Way! (book cover)

Starting today you can buy the PDF version of Learn Scala 3 The Fast Way! for just ten dollars — $10 (USD) — at this URL.

My 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 on

PDF version of Functional Programming, Simplified

Paperback Book
Now $29.99 on Amazon

Print version of Functional Programming, Simplified

Kindle eBook
$14.99 on Amazon

Kindle version of Functional Programming, Simplified

Since I’ve written two functional programming books, I thought it might help to provide a comparison of them. The short story is that both books have “limited technical jargon,” and as shown, The Little FP Book essentially has one purpose, which is to help Java/Kotlin/OOP developers learn functional programming as fast as possible, using a technique that I “discovered” over the last few years. Conversely, The Big FP Book covers many topics in great detail.

Here are links to the two books:

Functional programming books, comparison

When I was writing my new functional programming book — Learn Functional Programming Without Fear — a few alternate titles for the book were:

  • Learn Functional Programming the Fast Way!
  • The Fastest Way to Learn Functional Programming
  • From Object-Oriented Programming to Functional Programming
  • Helping Object-Oriented Programmers Learn Functional Programming
  • Functional Programming for Objected-Oriented Programmers

That’s because I found out — almost by accident — that the fastest way for object-oriented programming (OOP) developers to learn functional programming (FP) goes like this:

As a brief note today, I just released the first version of a new, free booklet that I’ve titled Learning Recursion.

Learning Recursion: A free booklet by Alvin Alexander

Note: This tutorial is an excerpt from the Scala Cookbook, 2nd Edition.

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.