Scala

Scala: Start What Scala is, the JDK and scala-cli, a first program, and the two commands that run the code. Open Scala: The basics Values and types, numbers, strings, operators as methods, expressions, loops, methods and imports. Open λ Scala: Functions Functions as values, higher-order methods, closures, currying, partial functions, tail recursion and by-name parameters. Open Scala: Object orientation Classes and constructors, objects and companions, traits, inheritance, export, opaque types and equality. Open Scala: Data modelling and pattern matching Tuples, case classes, enums, sealed hierarchies, matching, extractors, and Option, Either and Try. Open Scala: Collections Lists, vectors, sets, maps, arrays and ranges, the transformations, grouping and sorting, and their costs. Open <T> Scala: The type system Generics, variance and bounds, union and intersection types, givens, type classes, extensions and derives. Open Scala: Effects and concurrency Exceptions and resource handling, Future and Promise, execution contexts, virtual threads, files and the HTTP client. Open Scala: Testing and quality MUnit, ScalaTest, ScalaCheck properties, scalafmt, Scalafix, WartRemover and scaladoc. Open Scala: Builds and practice An sbt project and its tasks, tests and modules, packaging, Java interop, the ecosystem, and a finishing tool. Open

All articles

About the course

Scala is a language for the Java platform that puts a strong type system and functional programming on the same virtual machine as Java. It compiles to the bytecode a Java compiler writes, so a Scala class is a JVM class, a Java library needs no wrapper, and the two languages call each other without knowing which one wrote the file. The course is a chain of numbered lessons. Each one takes one idea, shows whole programs with their real output, and names the lesson before it and the lesson after it.

The language is Scala 3, and the course uses its syntax throughout: significant indentation, then, given and using, enum, extension methods, * imports and @main. Every program was compiled and run with Scala 3.10.1 on JDK 21, and every output block is copied from that run. scala-cli 1.19.0 is the runner; the compiler is scalac, and a build uses sbt 2.1.1. The code is written in the style scalafmt 3.11.5 produces with maxColumn = 100. A lesson that would need a library from the network says so and is not run, rather than showing an invented output.

The JUnit 5 platform runs the Scala test frameworks, and Gradle builds Scala projects with the same JVM toolchain. The Groovy course is the same platform with a dynamic language, and the Java pages hold the standard library the later lessons use.

Related