Scala
Functional and object-oriented, on the JVM.
Scala is taught here in 13 lessons, running from Syntax and immutability through to A small HTTP service with http4s or Play. Each lesson takes one topic, shows the working code, and links onward to the next, so the course can be read straight through in order.
| Track | Programming Languages |
| Lessons | 13 |
| Level | Beginner to intermediate |
| Reading time | about 3 hours |
| Prerequisites | Helpful, but not required: C# |
Lessons
- Syntax and immutabilityValues, inferred types, methods versus functions, and why Scala makes immutability the default you have to opt out of.
- Case classes and pattern matchingModel data with case classes, then take it apart with match — the two features that most Scala code is built from.
- Collections and functional styleThe collection hierarchy, the transformations you use daily, and for-comprehensions for readable pipelines.
- Setting up Scala 3: Coursier, Scala CLI and sbtInstall the toolchain with Coursier, run scripts with Scala CLI, and lay out an sbt project you can build and test from the terminal.
- Traits, classes and object-oriented ScalaCompose behaviour with traits, control access with modifiers, use companions and apply, and extend types with given-based syntax.
- Option, Either and functional error handlingReplace null with Option, carry failure reasons in Either, and use for-comprehensions to chain computations that may fail.
- Generics, variance and type boundsParameterise types, set upper and lower bounds, and get variance right so a subtype relationship survives inside a container.
- Givens, implicits and type classesDefine and consume given instances, resolve extension methods, and implement a type class the way the libraries do.
- Testing with ScalaTest and MUnitStructure suites and assertions, use property-based testing with ScalaCheck, and run the right tests from sbt and Scala CLI.
- sbt, dependencies and project structureWrite settings and tasks, manage libraries and resolvers, split a build into modules, and publish a versioned artifact.
- Concurrency: Futures, actors and effect systemsCompose asynchronous work with Future, recover from failure, use actors for stateful concurrency, and see what an effect system adds.
- Java interop and the JVM ecosystemCall Java from Scala and back, convert collections, handle nulls and exceptions at the boundary, and read a stack trace.
- A small HTTP service with http4s or PlayDefine routes, encode JSON with circe, wire configuration, add middleware and errors, and package the service to deploy.
More in Programming Languages
FAQ
How long does the Scala course take?
It has 13 lessons, about 3 hours of reading. Expect roughly twice that if you type out and run every example.
Do I need prior experience for Scala?
Not strictly. It helps to have read C# first, because some lessons build on it, but every lesson explains its own assumptions.
What should I read after Scala?
Continue with Lua (13 lessons), the next course in Programming Languages.