Tutorial 4
Generative Programming: Concepts and Experiences
Agile and Efficient Domain-Specific Languages using Multi-stage Programming in Java Mint
Abstract
Domain-specific languages (DSLs) are a powerful produc-
tivity tool because they allow domain experts, who are not
necessarily programming experts, to quickly develop pro-
grams. DSL implementations have unique constraints for
programming languages because they must be efficient, in
order to ensure high productivity, but they must also be ag-
ile, in order to meet the rapidly changing demands of their
domains. In this tutorial we show how multi-stage program-
ming (MSP) can be used to build staged interpreters, which
combine the agility of interpreters with the efficiency of
compilers. The tutorial is conducted in Java Mint, an multi-
stage Java based on recent work incorporating MSP into im-
perative object-oriented languages. In the first half of the tu-
torial, we introduce MSP by demonstrating how to write a
staged interpreter for a number of basic language constructs,
such as recursive functions, conditionals, and let expres-
sions. In the second half, we extend our staged interpreter
to take advantage of several well-known compiler optimiza-
tions, including type inference, constant folding, and static
parallel loop scheduling. We highlight the opportunities af-
forded by using MSP with object-oriented design to quickly
create efficient DSL implementations.
Author bios
Mathias Ricken is a doctoral candidate in the Programming
Languages Team at Rice University and one of the principal developers of the DrJava integrated development environment. His research interests include concurrent programming, extending the Java language, and computer science
education. He is the developer of the Concutest concurrent
unit testing framework and has created various experimental extensions of Java to address, for instance, programming
with meta-data. Currently, Mathias is contributing to Java
Mint, a multi-stage extension of Java that allows safe and
expressive statically typed program generation and specialization in an imperative language setting.
Edwin Westbrook is a post-doctoral researcher at Rice
University. His primary interests are in developing techniques for implementing and verifying properties of domain-specific languages (DSLs). He has worked on a number of
projects in this area, including: Cinic, a type theory for building machine-checked proofs of properties of DSLs using a
new approach to higher-order abstract syntax; Java Mint, a
multi-stage version of Java used for efficient implementations of DSLs; and Acumen, a DSL for designing cyber-physical systems.