Posts in the “scala” category

A unique Patreon gift: My book covers on coffee mugs

If you’re looking for a unique gift for yourself or the Scala computer programmer in your life, I just created these coffee mug designs here on my Patreon account. There are two different designs, one with four book covers and another with three book covers, and both of them completely wrap around the mug.

Supporting my Patreon account helps to keep me writing and teaching about Scala, so I’m trying to find new and unique ways to thank my supporters. If you like coffee, tea, or any other beverage in a mug, I hope you’ll like these new designs.

The fastest way to learn functional programming (for Java/Kotlin/OOP developers)

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

  • The Fastest Way to Learn Functional Programming
  • Learn Functional Programming the Fast Way
  • 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:

For OOP developers: The smallest, simplest functional programming book

Some of the programming books on the right side of this image are amazing, and I would never discourage anyone from reading the great ones.

But if you’re an object-oriented programming (OOP) developer who wants to start understanding functional programming (FP) over a weekend or a few nights of reading, that’s the goal of the new little book on the left: Learn Functional Programming Without Fear. It takes you from Java/OOP to functional programming in the simplest possible step-by-step learning process.

FP for Java/Kotlin/OOP developers

I taught Java and OOP for many years, and have used other OOP languages like Kotlin, Python, and Flutter/Dart, so I understand both OOP and FP, and I think that helped to make this a simple book for learning FP.

I also wrote the FP book in the middle — Functional Programming, Simplified — and it’s about three times larger than the little book on the left. I based it on most of the FP books on the right, and it goes into many details that the book on the left doesn’t go into. It’s big, but it’s still easier than reading all the books on the right.

Best FP book for OOP, Java, and Kotlin developers?

October, 2022: I just released my new book, Learn Functional Programming Without Fear, and my aim is to make it a terrific functional programming (FP) book for all OOP developers, especially Java and Kotlin programmers.

As a personal statement, I have no interest in pushing FP on anyone, but if you’re an OOP developer who is interested in FP, I hope this book is helpful. If you have some experience programming in Java, Kotlin, and OOP, I believe you’ll be able to read the whole book over a weekend, or in several nights during a week.

Update: It’s now December, 2022, and the book is still a “#1 New Release” on Amazon!

Why Java and Kotlin?

Why Java and Kotlin?:

  • For both of them, it’s because they’re JVM-based languages (or at least they were initially).
  • For Java developers, it’s because Java has incorporated several aspects of Scala over the last 12 years (including features like lambdas and immutable collections classes)
  • And for Kotlin developers, it’s because Kotlin and Scala are so similar. (My understanding is that Martin Odersky even consulted on the creation of Kotlin.) I’ve seen people say that if you know Scala, you can learn Kotlin in a week, and vice-versa.

FP for Java, Kotlin, and OOP developers

Scala: What do “effect” and “effectful” mean in functional programming?

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.

But fear not, this is surprisingly simple. As I write 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).

A “Minority Report” Monte Carlo simulation in Scala

This article shares the source code for a Monte Carlo simulation that I wrote in Scala. It was inspired by the movie Minority Report, as well as my own experience.


For the purposes of this simulation, imagine that you have three people that are each “right” roughly 80% of the time. For instance, if they take a test with 100 questions, each of the three individuals will get 80 of the questions right, although they may not get the same questions right or wrong. Given these three people, my question to several statisticians was, “If two of the people have the same answer to a given question, what are the odds that they are correct? Furthermore, if all three of them give the same answer to a question, what are the odds that they are right?”

How to disassemble and decompile Scala code (javap, scalac, jad)


This is an excerpt from the 1st Edition of the Scala Cookbook (partially modified for the internet). This is Recipe 14.6, “How to disassemble and decompile Scala code.”


In the process of learning Scala, or trying to understand a particular problem, you want to examine the source code and bytecode the Scala compiler generates from your original source code.


You can use several different approaches to see how your Scala source code is translated:

The easiest, simplest way to learn functional programming?

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.

What’s the easiest way to learn functional programming?

People occasionally ask me, “What’s the easiest way to learn functional programming?” If you look at all of the books on the right side of this image, I can tell you that reading all of those books wasn’t an easy way to learn functional programming (FP):

IMHO there’s a much easier way to learn the FP basics: I’ve made almost 40% of my book, Functional Programming, Simplified, freely available.

The lessons in the free PDF you can find at that URL include:

Functional programming books, comparison

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, Simplified: Updated for Scala 3 (book)

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.