Scalabook

About the project

ScalaBook is a continuously updated workbook on functional programming in Scala, covering the following topics:

In the era of multi-core processors and parallel computing, FP offers the following advantages:

Example:

// Problem of the imperative approach: hidden errors through exceptions
def divide(a: Int, b: Int): Int =
  if b == 0 then throw new Exception("Division by zero") else a / b

// FP solution: the fact that the function is not defined for every input
// is explicitly reflected in its type
def divide(a: Int, b: Int): Option[Int] =
  if b == 0 then None else Some(a / b)

Using Option makes impossible states (such as division by zero) visible at compile time, which reduces the number of runtime errors.

Algorithms and data structures

In the world of big data, inefficient algorithms lead to significant resource costs.

Example:

Checking list.length > 0 of a linked list for emptiness requires O(n) operations — for a list of one million elements this is a million extra operations. Whereas list.nonEmpty is a single operation.

Even with the rise of AI that can describe and explain code, understanding algorithms allows you to consciously choose solutions (for example, HashMap vs List for lookup) and optimize code in high-load systems.

Practical focus

Theory without practice is useless. Scalabook includes:

Main sections

Section Description
Functional programming Core concepts and principles of functional programming
Type classes Exploring type classes and category theory
Algorithms Implementing classic algorithms in a functional style
Data structures Functional data structures
Cats effect Overview of Cats effect - a pure asynchronous runtime
Tooling Overview of popular Scala libraries
Practicum Building a Scala application using functional programming principles
Translations Translations of articles, learning materials and talks into Russian. Solutions to exercises from various books and websites
Resources Useful links to books, articles, online courses and videos for deeper study

Project goal

Practice shows that Scala has a high entry barrier. That is the price of its expressiveness, flexibility and power. But is the high entry barrier a problem for developers who are just starting to learn Scala and FP? Rather, it is a problem for those who already know Scala, who have jumped across the gap, but cannot or do not want to build a bridge across that gap. And shout to others: "Jump too! I did it!"

ScalaBook's goal is to build that "bridge". A high entry barrier is not a reason for pride in "I did it!", but a reason to think: what have you done to lower that barrier?

Construction of the Manhattan Bridge, 1909:

Manhattan Bridge

Feedback

Your feedback is fuel for the project's development. Whether you fix typos, suggest new topics, or simply say "thank you" — every response matters.

How can you help?

Contacts