Monotonic References for Efficient Gradual Typing

  • Jeremy G. Siek
  • Michael M. Vitousek
  • Matteo Cimini
  • Sam Tobin-Hochstadt
  • Ronald Garcia
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9032)

Abstract

Gradual typing enables both static and dynamic typing in the same program and makes it convenient to migrate code regions between the two typing disciplines. One goal of gradual typing is to provide all the benefits of static typing, such as efficiency, in statically-typed regions. However, this goal is elusive: the standard approach to mutable references imposes run-time overhead in statically-typed regions and alternative approaches are too conservative, either statically or at run-time. In this paper we present a new semantics called monotonic references which imposes none of the run-time overhead of dynamic typing in statically typed regions. With this design, casting a reference may cause a heap cell to become more statically typed (but not less). Retaining type safety is challenging with strong updates to the heap. Nevertheless, we have a mechanized proof of type safety. Further, we present blame tracking for monotonic references and prove a blame theorem.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [Abadi et al.(1989)Abadi, Cardelli, Pierce, and Plotkin]
    Abadi, M., Cardelli, L., Pierce, B., Plotkin, G.: Dynamic typing in a statically-typed language. In: Symposium on Principles of programming languages (1989)Google Scholar
  2. [Bierman et al.(2010)Bierman, Meijer, and Torgersen]
    Bierman, G., Meijer, E., Torgersen, M.: Adding dynamic types to C#. In: European Conference on Object-Oriented Programming (2010)Google Scholar
  3. [Boyland(2014)]
    Boyland, J.T.: The problem of structural type tests in a gradual-typed language. In: Foundations of Object Oriented Languages, FOOL 2014, pp. 675–681. ACM (2014)Google Scholar
  4. [Fähndrich and Leino(2003)]
    Fähndrich, M., Leino, K.R.M.: Heap monotonic typestate. In: International Workshop on Alias Confinement and Ownership (2003)Google Scholar
  5. [Findler and Felleisen(2002)]
    Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: International Conference on Functional Programming, ICFP, pp. 48–59 (2002)Google Scholar
  6. [Flatt and PLT(2014)]
    Flatt, M.: The Racket reference 6.0. Technical report, PLT Inc (2014), http://docs.racket-lang.org/reference/index.html
  7. [Henglein(1994)]
    Henglein, F.: Dynamic typing: syntax and proof theory. Science of Computer Programming 22(3), 197–230 (1994)CrossRefMATHMathSciNetGoogle Scholar
  8. [Herman et al.(2007)Herman, Tomb, and Flanagan]
    Herman, D., Tomb, A., Flanagan, C.: Space-efficient gradual typing. In: Trends in Functional Prog (TFP), p. XXVIII (April 2007)Google Scholar
  9. [Rastogi et al.(2014)Rastogi, Swamy, Fournet, Bierman, and Vekris]
    Rastogi, A., Swamy, N., Fournet, C., Bierman, G., Vekris, P.: Safe & efficient gradual typing for TypeScript. Technical Report MSR-TR-2014-99 (2014)Google Scholar
  10. [Siek and Taha(2006)]
    Siek, J.G., Taha, W.: Gradual typing for functional languages. In: Scheme and Functional Programming Workshop, pp. 81–92 (September 2006)Google Scholar
  11. [Siek and Vitousek(2013)]
    Siek, J.G., Vitousek, M.M.: Monotonic references for gradual typing. In: Computing Research Repository (2013), http://arxiv.org/abs/1312.0694
  12. [Siek and Wadler(2010)]
    Siek, J.G., Wadler, P.: Threesomes, with and without blame. In: Symposium on Principles of Programming Languages, POPL, pp. 365–376 (January 2010)Google Scholar
  13. [Siek et al.(2015)Siek, Vitousek, Cimini, and Boyland]
    Siek, J.G., Vitousek, M.M., Cimini, M., Boyland, J.T.: Refined criteria for gradual typing. Under review for publication at SNAPL 2015 (2015)Google Scholar
  14. [Strickland et al.(2012)Strickland, Tobin-Hochstadt, Findler, and Flatt]
    Strickland, T.S., Tobin-Hochstadt, S., Findler, R.B., Flatt, M.: Chaperones and impersonators: run-time support for reasonable interposition. In: OOPSLA (2012)Google Scholar
  15. [Swamy et al.(2014)Swamy, Fournet, Rastogi, Bhargavan, Chen, Strub, and Bierman]
    Swamy, N., Fournet, C., Rastogi, A., Bhargavan, K., Chen, J., Strub, P.-Y., Bierman, G.: Gradual typing embedded securely in JavaScript. In: Symposium on Principles of Programming Languages, POPL (January 2014)Google Scholar
  16. [Tobin-Hochstadt and Felleisen(2006)]
    Tobin-Hochstadt, S., Felleisen, M.: Interlanguage migration: From scripts to programs. In: Dynamic Languages Symposium (2006)Google Scholar
  17. [Vitousek et al.(2014)Vitousek, Siek, Kent, and Baker]
    Vitousek, M.M., Siek, J.G., Kent, A., Baker, J.: Design and evaluation of gradual typing for Python. In: Dynamic Languages Symposium (2014)Google Scholar
  18. [Wadler and Findler(2009)]
    Wadler, P., Findler, R.B.: Well-typed programs can’t be blamed. In: European Symposium on Programming, ESOP, pp. 1–16 (March 2009)Google Scholar
  19. [Wrigstad et al.(2010)Wrigstad, Nardelli, Lebresne, Östlund, and Vitek]
    Wrigstad, T., Nardelli, F.Z., Lebresne, S., Östlund, J., Vitek, J.: Integrating typed and untyped code in a scripting language. In: Symposium on Principles of Programming Languages, POPL, pp. 377–388 (2010)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2015

Authors and Affiliations

  • Jeremy G. Siek
    • 1
  • Michael M. Vitousek
    • 1
  • Matteo Cimini
    • 1
  • Sam Tobin-Hochstadt
    • 1
  • Ronald Garcia
    • 2
  1. 1.Indiana University BloomingtonBloomingtonUSA
  2. 2.University of British ColumbiaVancouverCanada

Personalised recommendations