Shallow Types for Insightful Programs: Grace is Optional, Performance is Not

Languages with explicit dynamic type checking are increasing in popularity in both practical development and programming education. Unfortunately, current implementations of these languages perform worse than either purely statically or purely dynamically typed languages. We show how virtual machines can use common optimizations to remove redundancy in dynamic type checking, by adding shallow structural type checks to Moth, a Truffle-based interpreter for Grace. Moth runs programs with dynamic type checks roughly as fast as programs without checks, so developers do not need to disable checks in production code, and educators can teach types without also teaching that types slow programs down.

[1]  Ross Tate,et al.  Sound gradual typing is nominally alive and well , 2017, Proc. ACM Program. Lang..

[2]  Andrew P. Black,et al.  Seeking grace: a new object-oriented language for novices , 2013, SIGCSE '13.

[3]  Timothy Jones,et al.  Object Inheritance Without Classes , 2016, ECOOP.

[4]  Laurence Tratt,et al.  Storage strategies for collections in dynamically typed languages , 2013, OOPSLA.

[5]  Jeffrey S. Foster,et al.  Static type inference for Ruby , 2009, SAC '09.

[6]  Andrew P. Black,et al.  Grace: the absence of (inessential) difficulty , 2012, Onward! 2012.

[7]  BonettaDaniele,et al.  Efficient and thread-safe objects for dynamically-typed languages , 2016 .

[8]  Sam Tobin-Hochstadt,et al.  The design and implementation of typed scheme , 2008, POPL '08.

[9]  Christian Wimmer,et al.  Practical partial evaluation for high-performance dynamic language runtimes , 2017, PLDI.

[10]  Craig Chambers,et al.  An efficient implementation of SELF, a dynamically-typed object-oriented language based on prototypes , 1989, OOPSLA '89.

[11]  Sam Tobin-Hochstadt,et al.  Pycket: a tracing JIT for a functional language , 2015, ICFP.

[12]  Sam Tobin-Hochstadt,et al.  Monotonic References for Efficient Gradual Typing , 2015, ESOP.

[13]  Manuel V. Hermenegildo,et al.  Reducing the overhead of assertion run-time checks via static analysis , 2016, PPDP.

[14]  Andrew P. Black,et al.  The development of the Emerald programming language , 2007, HOPL.

[15]  Alexi Turcotte,et al.  The VM already knew that: leveraging compile-time knowledge to optimize gradual typing , 2017, Proc. ACM Program. Lang..

[16]  Hannes Payer,et al.  Memento mori: dynamic allocation-site-based optimizations , 2015, ISMM.

[17]  Jeremy G. Siek Gradual Typing for Functional Languages , 2006 .

[18]  Hanspeter Mössenböck,et al.  An object storage model for the truffle language implementation framework , 2014, PPPJ '14.

[19]  Sarah Mount,et al.  Virtual machine warmup blows hot and cold , 2016, Proc. ACM Program. Lang..

[20]  Philip Wadler,et al.  Blame for all , 2011, POPL '11.

[21]  Sam Tobin-Hochstadt,et al.  Optimization coaching: optimizers learn to communicate with programmers , 2012, OOPSLA '12.

[22]  Jan Vitek,et al.  Is sound gradual typing dead? , 2016, POPL.

[23]  Sabrina Eberhart,et al.  Common Lisp The Language , 2016 .

[24]  Yaron Kashai,et al.  Modules as Objects in Newspeak , 2010, ECOOP.

[25]  Jim Baker,et al.  Design and evaluation of gradual typing for python , 2014, DLS.

[26]  Ralph E. Johnson,et al.  Type-checking Smalltalk , 1986, OOPLSA '86.

[27]  Jeremy G. Siek,et al.  Big types in little runtime: open-world soundness and collaborative blame for gradual type systems , 2017, POPL.

[28]  Stéphane Ducasse,et al.  Tracing vs. partial evaluation: comparing meta-compilation approaches for self-optimizing interpreters , 2015, OOPSLA.

[29]  Hanspeter Mössenböck,et al.  Cross-language compiler benchmarking: are we fast yet? , 2016, DLS.

[30]  Gilad Bracha,et al.  Strongtalk: typechecking Smalltalk in a production environment , 1993, OOPSLA '93.

[31]  Martín Abadi,et al.  Dynamic typing in a statically-typed language , 1989, POPL '89.

[32]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

[33]  Christian Wimmer,et al.  A domain-specific language for building self-optimizing AST interpreters , 2014, GPCE.

[34]  John Tang Boyland,et al.  Refined Criteria for Gradual Typing , 2015, SNAPL.

[35]  Philip Wadler,et al.  Well-Typed Programs Can't Be Blamed , 2009, ESOP.

[36]  Martín Abadi,et al.  Understanding TypeScript , 2014, ECOOP.

[37]  Ben Greenman,et al.  On the cost of type-tag soundness , 2017, PEPM.

[38]  Jochen Eisinger,et al.  Idle time garbage collection scheduling , 2016, Commun. ACM.

[39]  Jeremy G. Siek,et al.  Efficient Gradual Typing , 2018, ArXiv.

[40]  O. Linton Local Regression Models , 2010 .

[41]  John Boyland The Problem of Structural Type Tests in a Gradual-Typed Language , 2014 .

[42]  Sam Tobin-Hochstadt,et al.  Sound gradual typing: only mostly dead , 2017, Proc. ACM Program. Lang..

[43]  Christian Wimmer,et al.  Self-optimizing AST interpreters , 2012, DLS.

[44]  Gilad Bracha Pluggable Type Systems , 2004 .

[45]  Ole Lehrmann Madsen,et al.  Object-oriented programming in the BETA programming language , 1993 .

[46]  Andrew P. Black,et al.  Panel: designing the next educational programming language , 2010, SPLASH/OOPSLA Companion.

[47]  Marc Feeley,et al.  Interprocedural Type Specialization of JavaScript Programs Without Type Analysis , 2016, ECOOP.