Learn Scala 3 The Fast Way: Your Setup For This Book

As we get close to the first programming lesson, let’s start getting your computer environment set up.

For most of the examples that are included in the book, all you need is a browser. I show this as “Setup Option #2” below because I don’t think it’s the best approach, but it’s still a good approach.

The reason it’s not the best approach is because I think the easiest way to run all of the source code examples in the book’s Github repository is to have Scala installed on your local computer. Therefore I present that as Option 1.

Setup Option 1: Install Scala CLI

I work at the command line all the time, so for the purposes of this book I recommend installing a tool named Scala CLI. By installing just this one tool, you’ll be able to run all of the examples I show in the book on your computer.

Some benefits of Scala CLI:

  • It runs on your computer, so it’s generally faster
  • This one tool downloads everything you need to run Scala
  • It can be used to run all of my Github source code snippets
  • It can also be used to run all of my Github scripts (which are small but complete Scala applications)
  • It lets you easily include third-party libraries in your code, such as libraries for HTTP, JSON, databases, testing, etc.
  • If/when your project gets to be large, Scala CLI has an option to export your settings to a Scala build tool like sbt or Mill

The main drawback of Scala CLI is that it will download things like Scala 3 and a version of Java, so it may require a few GB of storage space on your computer. (And yes, I understand that can be a big consideration.)

If you want to install and use Scala CLI, just use the Installation link on their website.

If you’re curious about how it works, jump to the Scala CLI lesson near the end of this book and check out its examples.

Setup Option 2: Scastie

A second option is that if you don’t want to install anything on your computer, you can also run most of the book’s examples online at the Scastie website.

Scastie is a tool that’s created and maintained by the creators of Scala 3, and it lets you run Scala code in your browser. All you have to do is type in your code, press Run, and see the output.

If you’re not sure

If you’re not sure what you want, go ahead and start with Scastie, because it doesn’t require anything to be installed on your computer. But if/when you get to a point where you want to start running things on your local computer, come back here and install Scala CLI.


A third option — which in 2021 was the primary option for working at the command line — is to install the Scala SDK either by (a) manually downloading it, or (b) installing it with another tool like SDKMAN. However, I believe that Scala CLI is a significant improvement over this approach, so I recommend it instead.

At the time of this writing there is a proposal that Scala CLI should become the future of Scala at the command line, that’s how good it is.

Exercises and examples

As I mentioned in the Welcome to Scala 3! chapter, the main page for the online exercises can be found at this URL:

And the Github examples are at this URL:

books by alvin