Learn Scala 3 The Fast Way: Welcome to Scala 3!

Now that you know about my background, let me welcome you to this book, which is an introductory book about the Scala 3 programming language — the most modern, expressive, consistent, interesting, programming language I know.

Scala 3!

In this book I will often say “Scala 3” and not just “Scala.” That’s because Scala 3 — which was released in the summer of 2021 — has some significant changes from Scala 2, and I generally won’t be writing about those differences. Scala 3 is the future of Scala, so that’s all this book focuses on.

Who this book is for

I want to be really clear that this book is for developers who are new to Scala, and want to learn the latest version of Scala. It is for beginners, people who are new to Scala 3.

While I expect that you are new to Scala 3, I do assume that you have a little programming background. My assumptions are:

  • You have used another programming language, such as Java, C#, Python, C, or another language
  • This means that you have seen how to write at least a little bit of code, and also compile that code (if necessary) and run it
  • You may have used Scala 2, but you’re still beginning with it
  • You are familiar enough with object-oriented programming (OOP) that you know what a class is
  • You’re comfortable working at your operating system command line

Why this book is unique

I think the most unique thing about this book is that it’s for people who want to remember what they learn. When I came across the book, A Smarter Way to Learn JavaScript, I was really impressed with the online, interactive component of that book, so I’ve based a lot of my approach on that book, along with my additional research about how human beings learn and remember new things.

So helping you remember what you learn is THE primary goal of this book. To help achieve that goal, this book has a Github source code repository you can download and experiment with, and a companion website with exercises for each lesson.

Many — many! — studies show that humans don’t learn by simply reading. We have to do other things like work through exercises and write code to retain what we learn, so this emphasis is a HUGE thing that makes this book different and unique!

My own experience from my college days was that the only possible way I could pass a thermodynamics class was to work all the exercises. Initially I tried what I had always done — which was to read the book and then pass the tests — but that failed miserably (literally). That’s when I came across this quote:

“One learns by doing the thing.”

When I read that quote I realized I wasn’t really putting in the work that was necessary to pass this class, and I clearly wasn’t learning. This was one of those “lightbulb going on over your head” moments in life, and it became clear that the only way I was going to pass this class was to work all the exercises in the book.

Exercises and code examples

When this book is complete I plan to provide a link directly to each lesson’s exercises. But in this early release I’ll just share this one link which takes you to the index of all the lessons:

The exercises won’t take long, and most importantly, they often present the material in a way that’s different from the book to test your understanding.

Initially I was a little hesitant about the value of this approach, but after I started writing the exercises and showing them to other people, I got really excited about how much these lessons can help people learn Scala faster. It’s amazing what happens when you put a book down and then try to answer questions about what you just read! I expect that all of my books in the future will use this approach.

You’ll also find that these exercises are a great way to test your knowledge in the future. For instance, imagine that you get away from using what you learned for a week or two. In that situation you can come back to the exercises (rather than re-reading the book) to see what you really remember.

In addition to the online exercises, the book also has a corresponding Github repository of example code that you can use and modify:

This is a small Scala 3 book

One additional note I want to add is that writing a small book on Scala is hard. If you look at the landscape of Scala books you’ll see that many of them are 600 pages or more. That’s because of two things:

  • Scala has a lot of terrific features, and we want to write about them all
  • Scala is an object-oriented programming (OOP) language as well as a functional programming (FP) language, and in some cases — such as covering the Scala collections classes — that means there are OOP and FP versions of each class

I’ve learned that if you want to write a book about all of Scala, it’s just going to take a lot of pages.

This also means that if one of your goals is to write an introductory book in 250 pages or less, you can’t write about everything. Therefore, I’ve had to make some tough decisions about what to include in this book and what to leave out.

So that’s how this became a book for Scala 3 beginners. I decided to forget about writing about everything in one book, and just focus on the basics.

So my goal is to get you started on the basics of Scala 3, BUT, I do cover many features in this book, and once you understand them, I believe it will be much easier to learn the rest of them. I may follow this book up with another book to take your knowledge to the next level, or you can learn those features in the Scala Cookbook (2nd Edition), which was also written for Scala 3.

books by alvin