Scala

A JVM language combining object-oriented and functional programming for scalable, concurrent systems.

Object-Oriented
Functional
Advanced
2004
Martin Odersky

Overview

Scala is a strong statically typed language that fuses functional and object-oriented programming. It runs on the JVM and interoperates seamlessly with Java. Scala's expressive type system, pattern matching, and immutability-first approach make it particularly suited for building scalable distributed systems. Apache Spark is written in Scala.

Key Features

  • Functional + OOP — Seamlessly blends both paradigms
  • Powerful type system — Higher-kinded types, type classes, path-dependent types
  • Pattern matching — Deep structural matching on case classes
  • Immutability by default — val over var philosophy
  • Akka — Actor-based concurrency for distributed systems

Code Example

scala
case class Person(name: String, age: Int)

val people = List(Person("Alice", 30), Person("Bob", 17), Person("Charlie", 25))

val adults = people.collect {
  case Person(name, age) if age >= 18 => s"$name (age $age)"
}
println(adults.mkString(", "))

Learning Resources

Learning Path

14 topics across 4 sections

1Basics

2FP & Pattern Matching

  • Case Classes — Immutable data, copy(), and structural equality
  • Pattern Matching — Match expressions, guards, extractors, and sealed traits
  • Options & Either — Safe null handling and error representation
  • Collections — List, Map, Set — immutable by default, map/flatMap/filter

3Types & Traits

  • Traits — Stackable modifications, mixins, and linearization
  • Generics — Variance, bounds, and context bounds
  • Implicits / Given — Implicit conversions, type classes, and Scala 3 given/using

4Concurrency & Big Data

  • Futures — Asynchronous computation with Future and ExecutionContext
  • Akka Actors — Actor model for concurrent and distributed systems
  • Apache Spark — RDDs, DataFrames, and distributed data processing