Foundations of Professional Scala
Scala gets written in two broad styles, as a more concise Java and as a functional language, and most books stick to one of them. This one starts in the first style and works its way to the second. Nearly every page has something to type and run, and the explanation comes after you’ve seen what the code does.
What’s in the book
Part I: Scala for Java developers
These chapters stay close to Java and cover values, case classes, collections, Option and testing.
Part II: Getting the compiler to do the work
This part adds functions as values, types that model the problem and errors as ordinary values, then generics and givens.
Part III: Effects
Programs that do input and output and run concurrently, written with Cats Effect and fs2. The last chapter does the same work in direct style.
Part IV: A real service
The project gets an sbt build, an HTTP API, a Postgres database, more tests and a Docker image. The last chapter is about Play.
Appendices
Short guides to Scala 2 code and to the libraries the book doesn’t use.
Questions and answers
Is the book free?
Yes. You can read the whole book on this site or download it in ePub, mobi or PDF format. The code for every chapter is a download as well.
Who is it for?
Java developers who would like to start working in Scala. You should already be able to program and know your way around Java’s classes, lambdas, streams and build tools. You don’t need to have seen any Scala before, or know anything about functional programming yet.
Which versions of Scala and Java does it use?
Scala 3.9 on JDK 25. Chapters 1 to 17 use Scala CLI, which is the scala command, and Part IV builds the service with sbt 2.
Which libraries does it use?
Cats Effect and fs2 for effects and streams, Tapir on http4s for the HTTP API, circe for JSON, doobie and Flyway for Postgres, and MUnit, ScalaCheck and Testcontainers for tests. There’s a chapter on direct style with Ox and one on Play.
Does it cover Scala 2, ZIO or Spark?
Briefly. The code in the book is Scala 3. Appendix A shows how to read Scala 2, since a lot of existing code is written in it, and ZIO and Spark each get a section in appendix B.