Newspeak and Trufle : A Platform for Grace ?

The Newspeak language had a strong inluence on Grace’s language design: Is a Newspeak interpreter a good starting point for a Grace implementation? Trule is a framework for interpreter implementation and leverages the Graal just-in-time (JIT) compiler to ofer stateof-the-art performance to dynamic languages. But does it fulill the promise, and at which cost? This talk is a review of about two years of work on a Grace implementation based on SOMns called Moth. What did we achieve? How compliant is Mothwith the speciication? How much of SOMns can we reuse to support Grace? Does Trule live up to the promise? 1 Why another Grace implementation? Perhaps the irst question to answer when deciding to implement a language is the goal of the new language implementation. While widely used languages beneit from new implementations simply by exposing ambiguity and holes in the speciications, for Grace there are not yet enough users to justify such an investment. From the outset, Grace was designed as a language for teaching and research. Looking at its four or ive implementations, we see that most of them are interpreters (Kernan is an interpreter built in C#) or compilers to other languages (Minigrace compiles to C and JavaScript). None of these implementations focus on performance. Performance can be a major hurdle for some research questions. For instance, metaobject protocols have been considered impractical for about twenty years, until it could be shown that their performance issues can be solved [Marr et al. 2015]. Similarly, there is an open question about whether gradual typing can be supported eiciently in a practical implementation [Takikawa et al. 2016]. While eiciency was not a goal of the language design [Black et al. 2010], the language should not gratuitously include features that cannot be implemented eiciency. Grace’s current design now includes several features (gradual typing, a deeply nested object model, language extension via dialects, inheritance from łfresh objectsž, method Grace’18, November, 04, 2018, Boston, MA, USA © 2018 Copyright held by the owner⁄author(s). This is the author’s version of the work. It is posted here for your personal use. Not for redistribution. The deinitive Version of Record was published in Proceedings of Grace Workshop at SPLASH’18 (Grace’18). aliasing over inheritance) that are suiciently novel or complex that their eicient implementation cannot be taken for granted. To validate the language design, then, we need to demonstrate an implementation that achieves performance comparable with contemporary implementations of competing languages. This means the performance goal for our new Grace implementation (called łMothž [Hopper 1947]) is to reach performance on a level comparable to JavaScript. We aim to reach that goal without requiring a customVM, a team of 100 engineers, and resources that even large companies struggle to provide. 2 How do Newspeak and Trufle it into the mix? Self [Chambers et al. 1989] and Newspeak [Bracha et al. 2010] had amajor inluences onGrace’s design. Self inspires Grace’s foundation upon objects, rather than classes, and its view of computation as requesting messages. Newspeak inspires Grace’s ubiquitous nesting used to represent related abstractions, and in particular, to simulate classes with objects. As such, an early idea was that one may be able to adapt an existing Newspeak implementation with comparably little efort to execute Grace programs. This intuition was conirmed with a one-week efort of getting Grace running on top of a Newspeak implementation simply by translating the AST from an existing Grace parser. SOMns is a Newspeak implementation on top the Trule framework and the Graal JIT compiler [Würthinger et al. 2013, 2017]. SOMns is implemented as an abstract-syntaxtree (AST) interpreter, which represents the language semantics directly as AST nodes. Compared to more traditional compilers and bytecode interpreters, an AST interpreter can avoid most compile-time analyses of the input program, and realize all aspects of the language semantics at run time. While this approach drastically simpliies an implementation, doing essentially all the work of checking and evaluating a program at run time means that a naïve AST interpreter will be slow. SOMns leverages the Java Virtual Machine, Graal compiler, and Trule framework so that its AST interpreter reaches the performance of V8 JavaScript [Marr et al. 2016]. This made SOMns appealing as platform for a new Grace implementation that has performance as a major goal.