Cast insertion strategies for gradually-typed objects

Gradual typing enables a smooth and progressive integration of static and dynamic typing. The semantics of a gradually-typed program is given by translation to an intermediate language with casts: runtime type checks that control the boundaries between statically- and dynamically-typed portions of a program. This paper studies the performance of different cast insertion strategies in the context of Gradualtalk, a gradually-typed Smalltalk. We first implement the strategy specified by Siek and Taha, which inserts casts at call sites. We then study the dual approach, which consists in performing casts in callees. Based on the observation that both strategies perform well in different scenarios, we design a hybrid strategy that combines the best of each approach. We evaluate these three strategies using both micro- and macro-benchmarks. We also discuss the impact of these strategies on memory, modularity, and inheritance. The hybrid strategy constitutes a promising cast insertion strategy for adding gradual types to existing dynamically-typed languages.

[1]  Michael Furr Combining Static and Dynamic Typing in Ruby , 2009 .

[2]  Nicolas Tabareau,et al.  A practical monadic aspect weaver , 2012, FOAL '12.

[3]  Cormac Flanagan,et al.  Space-efficient gradual typing , 2010, High. Order Symb. Comput..

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

[5]  Walid Taha,et al.  Gradual Typing for Objects , 2007, ECOOP.

[6]  Sam Tobin-Hochstadt,et al.  Interlanguage migration: from scripts to programs , 2006, OOPSLA '06.

[7]  Sam Tobin-Hochstadt,et al.  Logical types for untyped languages , 2010, ICFP '10.

[8]  Cormac Flanagan,et al.  Hybrid type checking , 2006, POPL '06.

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

[10]  Philip Wadler,et al.  Threesomes, with and without blame , 2010, POPL '10.

[11]  Robert Cartwright,et al.  Soft typing , 2004, SIGP.

[12]  Ralph Johnson,et al.  Type-Checking Smalltalk , 1986, OOPSLA.

[13]  Avik Chaudhuri,et al.  The ins and outs of gradual type inference , 2012, POPL '12.

[14]  Sam Tobin-Hochstadt,et al.  Gradual typing for first-class classes , 2012, OOPSLA '12.

[15]  Shriram Krishnamurthi,et al.  Typing Local Control and State Using Flow Analysis , 2011, ESOP.

[16]  Gilad Bracha Pluggable Type Systems , 2004 .

[17]  Sophia Drossopoulou,et al.  Towards Type Inference for JavaScript , 2005, ECOOP.

[18]  Oscar Nierstrasz,et al.  Practical, pluggable types for a dynamic language , 2009, Comput. Lang. Syst. Struct..

[19]  Roel Wuyts,et al.  Fast type reconstruction for dynamically typed programming languages , 2009, DLS '09.

[20]  Jonathan Aldrich,et al.  Integrating Nominal and Structural Subtyping , 2008, ECOOP.

[21]  Walid Taha,et al.  Exploring the Design Space of Higher-Order Casts , 2009, ESOP.

[22]  Avik Chaudhuri,et al.  The impact of optional type information on jit compilation of dynamically typed languages , 2011, DLS '11.

[23]  Oscar Nierstrasz,et al.  Traits: Composable Units of Behaviour , 2002, ECOOP.

[24]  Sam Tobin-Hochstadt Typed scheme: From scripts to programs , 2010 .

[25]  Jan Vitek,et al.  Thorn: robust, concurrent, extensible scripting on the JVM , 2009, OOPSLA '09.

[26]  Jonathan Aldrich,et al.  Is Structural Subtyping Useful? An Empirical Study , 2009, European Symposium on Programming.

[27]  Atsushi Igarashi,et al.  Gradual typing for generics , 2011, OOPSLA '11.

[28]  Justin O. Graver,et al.  TS: an optimizing compiler for smalltalk , 1988, OOPSLA 1988.

[29]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

[30]  Davide Ancona,et al.  RPython: a step towards reconciling dynamically and statically typed OO languages , 2007, DLS '07.

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

[32]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

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

[34]  Marcus Denker,et al.  Gradual typing for Smalltalk , 2014, Sci. Comput. Program..

[35]  Matthias Felleisen,et al.  Contracts for higher-order functions , 2002, ICFP '02.

[36]  Éric Tanter,et al.  Gradual Typestate , 2011, ECOOP.

[37]  Jens Palsberg,et al.  Proceedings of the 37th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages , 2010, POPL 2010.

[38]  Éric Tanter,et al.  Programming with Ghosts , 2013, IEEE Software.

[39]  Jan Vitek,et al.  Integrating typed and untyped code in a scripting language , 2010, POPL '10.

[40]  Ralph E. Johnson,et al.  A type system for Smalltalk , 1989, POPL '90.