May 3-6, 2015 Asilomar, California

The Design of Terra: Harnessing the Best Features of High-Level and Low-Level Languages

Zachary DeVito, Pat Hanrahan

Applications are often written using a combination of high-level and low-level languages since it allows performance critical parts to be carefully optimized, while other parts can be written more productively. This approach is used in web development, game programming, and in build systems for applications themselves. However, most languages were not designed with interoperability in mind, resulting in glue code and duplicated features that add complexity. We propose a two-language system where both languages were designed to interoperate. Lua is used for our high-level language since it was originally designed with interoperability in mind. We create a new low-level language, Terra, that we designed to interoperate with Lua. It is embedded in Lua, and meta-programmed from it, but has a low level of abstraction suited for writing high-performance code. We discuss important design decisions --- compartmentalized runtimes, glue-free interoperation, and meta-programming features --- that enable Lua and Terra to be more powerful than the sum of their parts.