Learning Scala in small bites

[article index] [] [@mattmight] [rss]

In my advanced compilers course, students have write to lexer-generators, parser-generators and Scheme interpreters with first-class macros.

To make these projects feasible, I recommend using Scala.

Of course, Scala is a large, intricate language.

It takes time to even become aware of all its features.

To help learn Scala faster, I've created the series of small examples below, each of which highlights one or two aspects of the language.


Updated, 16 Sep 2013: While teaching advanced compilers again this semester, I've significantly revamped and updated this tutorial. The code that broke with the big Scala collections update is running again. It all runs in the latest Scala.

Learning with the REPL

One of the useful features for learning Scala is its REPL (read-eval-print-loop) support. If you want to try something out in Scala, just run:

   % scala
and then try it out at the prompt.

Examples

Each well-commented script below demonstrates a different facet of Scala.

Demo micro-applications

Further reading

If you're looking for the next step after playing with these examples, I recommend Programming in Scala:

Lead-author Martin Odersky is the creator of the Scala language, and he can clearly articulate the rationale for every language feature.

Related pages