index.scala // Jump To …

Tutorials and Documentation

This tutorial series introduces Lightweight Modular Staging (LMS), a framework for
runtime code generation in Scala.

Outline:

Quick Start

These docs are a collection of literate Scala files. Clone the GitHub repo:

git clone https://github.com/scala-lms/tutorials.git

Check the README.md file for prerequisites and start hacking!

Why Generative Programming ?

Because it enables abstraction without regret: the key idea is to write very high-level
and generic programs that generate specialized and extremely fast low-level code at runtime.

Programming abstractions that would usually be avoided in performance-sensitive code
(objects, type classes, higher-order functions) can be used during generation without
affecting performance of the generated code.

Why LMS ?

Because it is lightweight and modular: LMS is just a Scala library. With types, it distinguishes
expressions that are evaluated now (type T) vs later (type Rep[T]).

LMS comes with batteries included: it provides many optimizations such as common subexpression elimination out of the box, and it goes beyond purely generative approaches by
providing an extensible intermediate representation that can be used to implement
sophisticated domain-specific compiler pipelines.

At the same time LMS is hackable: since it is just a library, all aspects can be
modified or extended to suit a particular purpose.

Self-Contained Tutorials

The following tutorials are available:

LMS In Depth

The material below has been extracted from Tiark's PhD thesis (PDF) and is still undergoing
revision for the web.

  1. About generative programming
  2. Generative programming and LMS basics
  3. Intermediate representation and optimizations
  4. Staging and LMS at work

Comments? Suggestions for improvement? View this file on GitHub.