💾 Archived View for dcreager.net › papers › Amin2017.gmi captured on 2023-12-28 at 15:29:13. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-11-04)

-=-=-=-=-=-=-

Amin2017

Nada Amin and Tiark Rompf. 2017. Collapsing towers of interpreters. Proc. ACM Program. Lang. 2, POPL, Article 52 (January 2018), 33 pages.

Remarkable PDF

Original PDF

DOI

Abstract

Given a tower of interpreters, i.e., a sequence of multiple interpreters interpreting one another as input programs, we aim to collapse this tower into a compiler that removes all interpretive overhead and runs in a single pass. In the real world, a use case might be Python code executed by an x86 runtime, on a CPU emulated in a JavaScript VM, running on an ARM CPU. Collapsing such a tower can not only exponentially improve runtime performance, but also enable the use of base-language tools for interpreted programs, e.g., for analysis and verification. In this paper, we lay the foundations in an idealized but realistic setting.

We present a multi-level lambda calculus that features staging constructs and stage polymorphism: based on runtime parameters, an evaluator either executes source code (thereby acting as an interpreter) or generates code (thereby acting as a compiler). We identify stage polymorphism, a programming model from the domain of high-performance program generators, as the key mechanism to make such interpreters compose in a collapsible way.

We present Pink, a meta-circular Lisp-like evaluator on top of this calculus, and demonstrate that we can collapse arbitrarily many levels of self-interpretation, including levels with semantic modifications. We discuss several examples: compiling regular expressions through an interpreter to base code, building program transformers from modi ed interpreters, and others. We develop these ideas further to include reflection and reification, culminating in Purple, a reflective language inspired by Brown, Blond, and Black, which realizes a conceptually infinite tower, where every aspect of the semantics can change dynamically. Addressing an open challenge, we show how user programs can be compiled and recompiled under user-modified semantics.

Notes

Have considered a similar “tower of stacks” setup in Swanson

Towers of stacks

BibTeX

@article{10.1145/3158140,
author = {Amin, Nada and Rompf, Tiark},
title = {Collapsing Towers of Interpreters},
year = {2017},
issue_date = {January 2018},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
volume = {2},
number = {POPL},
url = {https://doi.org/10.1145/3158140},
doi = {10.1145/3158140},
journal = {Proc. ACM Program. Lang.},
month = {dec},
articleno = {52},
numpages = {33},
keywords = {staging, reflection, interpreter, compiler, Lisp, Scala}
}