What Scala is

Scala is a language for the Java platform: it compiles to the bytecode a Java compiler writes, so a Scala class is an ordinary JVM class, a Java library needs no adapter, and a Java program can call a Scala one without knowing it is Scala. The language was designed by Martin Odersky and appeared in 2004; Scala 3, the version this course teaches, arrived in 2021 with a new metaprogramming model, enum, given and significant indentation. The name is short for "scalable language": the same syntax carries a three-line script and a distributed data engine.

A first program is one entry point and one line, and the collections it uses are immutable by default:

hello.scala

@main def hello(): Unit = val languages = List("Scala", "Java", "Kotlin") languages.foreach(name => println(s"Hello, $name"))

scala-cli run --server=false hello.scala

Hello, Scala
Hello, Java
Hello, Kotlin

val declares a value that never changes, List is a linked list of the standard library, and foreach takes a function. Nothing here needs a class, a type annotation or a semicolon.

Java underneath

The type system is the part Java does not have. A case class is a value with a name, an equality, a toString and a copy written by the compiler, and a pattern such as point.x reads a field without a getter:

points.scala

case class Point(x: Int, y: Int) @main def points(): Unit = val points = List(Point(1, 2), Point(3, 4)) val moved = points.map(point => point.copy(x = point.x + 10)) println(moved) println(moved.map(_.x).sum)

scala-cli run --server=false points.scala

List(Point(11,2), Point(13,4))
24

The Java library is there under the Scala names. java.time, java.nio, java.net.http and the rest of the JDK are imported as they are, which is why a Scala program can use every library the platform has:

dates.scala

import java.time.LocalDate @main def dates(): Unit = val date = LocalDate.of(2026, 11, 26) println(date.plusDays(5)) println(date.getDayOfWeek) println(date.getYear)

scala-cli run --server=false dates.scala

2026-12-01
THURSDAY
2026

Where Scala is used

The language lives where a JVM program has to be correct and fast at the same time. Apache Spark, the data engine of most batch pipelines, is written in Scala and exposes its API in it; Apache Kafka, the log that event-driven systems are built on, is Scala too. Akka and its successor Pekko implement the actor model in Scala, Play and http4s serve web applications, and the build tool sbt configures a project with a Scala file (build.sbt). The Java platform underneath means a team can add Scala to a Java codebase one module at a time.

Scala is also a teaching language: its type system carries ideas such as type classes, variance and immutability that other languages spell differently. The later chapters of this course take them one at a time, and every lesson is a whole program whose output is copied from a real run of it.

What Scala adds

Where to go next

The next lesson installs the toolchain and reads the version lines; Install Scala links one page per system. The first program then writes a whole program, and scalac and Java takes the same code to a class file that java runs.

Related

Article author: Arthur Isaev