Skip to content

What is Scala?

Updated Nov 30, 20263 min readBased on official documentation
What is Scala?

In short

Scala is a general-purpose programming language that runs on the Java Virtual Machine (JVM). It mixes object-oriented and functional programming in one language, and it can use any Java library. Developers use it for backend services, data processing and tools.

What Scala is

Scala is a statically typed language. That means the compiler checks types before your program runs, so many mistakes show up early. It compiles to bytecode for the Java Virtual Machine (JVM), the same runtime that runs Java programs. Because of this, Scala code can call Java classes directly, and Java code can call Scala classes. You get access to the large Java ecosystem without giving up a modern language.

Scala combines two styles of programming. The object-oriented side gives you classes, traits and inheritance. The functional side gives you immutable values, first-class functions and pattern matching. You can choose how much of each you use, so a team can start with a familiar style and move toward the functional one over time.

The official documentation is split into several tracks. The Scala 3 Book is a series of short lessons, and the Tour of Scala covers core features in small steps. The Guides and Overviews section goes deeper into the language, and the Language Reference describes Scala 3 rules in detail. The Language Spec is the formal definition for each major version, which is useful when you need an exact answer.

Scala 2 and Scala 3

You will see two major versions in the wild. Scala 2 has been around for many years and still has a large body of libraries and production code. Scala 3 is the newer generation. The documentation includes a Migration Guide that explains how to move a Scala 2 codebase to Scala 3, and a page called New in Scala 3 that lists the main changes.

When you start a new project, pick the version you want to target first. Check the version of every library you need, because not all libraries have moved at the same pace. The Scala FAQ on the official site is a good place to check common questions about versions and compatibility.

How it works in practice

Scala is built with a tool called sbt, a build tool widely used in the Scala world. sbt downloads dependencies, compiles the code and runs tests. The official site also offers installation instructions, so you can set up a working environment on your own machine in a short time. Once installed, you write source files, compile them and run the resulting program on the JVM.

A few features appear often in everyday Scala code. Immutable values are declared with val, and mutable variables use var. Case classes give you data types with equality and copying built in. Pattern matching lets you branch on the shape of a value. Collections in the standard library offer map, filter and fold operations, so you can process data with short expressions instead of manual loops.

Common mistakes

Beginners often try to write Scala as if it were Java with different punctuation. The result is code that works but misses the strengths of the language. Read the Style Guide early. It explains idiomatic patterns, such as preferring immutable values and expressions over statements that change state.

Another common issue is ignoring the implicit rules and the many syntax options. Scala gives you several ways to write the same thing. Stick to one style within a project, and use the Cheatsheet as a quick reminder while you learn. If you want to understand how functions passed around as values work, our page on what a closure is explains the idea in plain terms.

Alternatives

If you want a JVM language with a simpler feel, Java and Kotlin are the closest options. If your main interest is functional programming on a different runtime, you might look at other languages in our Learn section. For example, our page on Clojure describes another language that runs on the JVM and puts functional ideas first. Choose based on your team, your libraries and the kind of work you need to do.

FAQ

Do I need to know Java to learn Scala?

It helps but is not required. Scala runs on the JVM and can use Java libraries, so knowing some Java makes the ecosystem easier to navigate. Many people learn Scala directly, starting with the Scala 3 Book.

What is the difference between Scala 2 and Scala 3?

Scala 3 is the newer major version with a revised syntax and several new features. The official Migration Guide and the New in Scala 3 page describe the changes in detail.

Where can I find the official Scala language specification?

The documentation site links to a formal Language Spec for Scala 2.x and another for Scala 3.x. These are the reference for exact rules, so they are better for detailed questions than for first lessons.

Is Scala only used for big data?

No. Scala is a general-purpose language. It is often used for backend services and data tools, but the same language can be used for many kinds of programs.

Sources

This page is based on the official documentation below. Read it for full detail.

Scala — official documentation ↗
blozhikDeveloper news from across the web, explained. Every story links to its original sources.