Tutorials about the Scala programming language.

Version 0.1.3 of Learning Functional Programming in Scala alvin June 25, 2017 - 2:22pm

The next version of my book, Learning Functional Programming in Scala, is now available. See that link for details.

Learning Functional Programming in Scala (pdf)

Table of Contents1 - What’s new (June 25, 2017)2 - Buying the book3 - One more thing4 - Preview5 - Some time in the future ...

My new book, Learning Functional Programming in Scala, is currently available as a PDF you can purchase for just $10 US. (The price is going up to $25 this Saturday.) Details are listed below.

Back to top

What’s new (June 25, 2017)

If you’ve been following along with me recently, the latest changes are:

How I came to write the Scala Cookbook alvin June 22, 2017 - 10:24am

The funny thing about writing the Scala Cookbook is that it started as a whim. I was just about to leave for a vacation at the beach, and right before I turned off the computer, a thought flashed in my mind, “I should contact the people at O’Reilly about writing a cookbook for Scala.” I then had a doubt that they would actually do it, but I applied the “What the heck” rule — i.e., “What the heck, what do I have to lose?” — and sent the email.

I dug around the internet for a few minutes, found the correct O’Reilly email address, sent them a message, turned off the computer, and drove to the beach. While I was at the beach the publisher wrote and said, “Love it, send me a full proposal!”

So if you’re thinking about doing something, but are afraid or uncertain about doing it ... apply the “What the heck” rule, and give it a shot. :)

Next version of Scala/FP book, coming soon alvin June 20, 2017 - 5:10am

Update 1: The next version of my book on Scala and functional programming will be released later this week.

Update 2: The price of the book will be increased to $25 on July 1, 2017.

The Scala spectrum: OOP to Pure FP alvin June 17, 2017 - 10:35am

Scala is a great language in many ways. One great feature is that you can use it as a “Better Java” (i.e., as an OOP language), and you can also use it as a pure FP language. While some people prefer one extreme or the other (not unlike extremist Republicans and Democrats in the U.S.), I appreciate that this lets you find a “Middle Way” of using the best features of both approaches.

Scala: How to read input from one file while writing output to another file alvin June 14, 2017 - 3:53pm

Without much introduction or discussion, here’s a Scala example that shows how to read from one text file while simultaneously writing the uppercase version of the text to a second output file:

A good reason to use sealed traits and classes in Scala alvin June 13, 2017 - 1:23pm

This documentation page shares a good reason to use “sealed” traits and classes: When you do this, the compiler can easily tell all of the subtypes of your class or trait, and therefore you don’t need to add a default, “catch-all” case in your Scala match expressions.

An example Scala ‘App’ for the Cats “IO Monad” article alvin June 11, 2017 - 7:38pm

As a quick note, if you’re interested in using the IO monad described in this IO Monad for Cats article, here’s the source code for a complete Scala App based on that article: books alvin June 11, 2017 - 2:46pm

The people at have made their books on Scala and functional programming free (or “donationware,” if you prefer). I’ve found the Advanced Scala with Cats book to be particularly good, and well worth a donation.

(Full disclosure: I didn’t pay for the Advanced Scala book when I first downloaded it, then went back and tried to pay for it, but the Gumroad website wouldn’t let me do that.)

Just trying to be a reporter alvin June 11, 2017 - 1:35pm

After the 0.1.2 release of Learning Functional Programming in Scala, it occurs to me that I need to be more explicit about my goals for the book. Some people seem to think that I’m trying to “sell” functional programming. That’s not the case at all. I’m just trying to be a reporter and explain what I’ve learned about FP after reading dozens (hundreds?!) of articles and many books on FP, learning Haskell, trying to apply these techniques to my own code, etc. I’ll explain this further in the next release of the book.