skip to main content
research-article
Public Access

Automatically generating the dynamic semantics of gradually typed languages

Published:01 January 2017Publication History
Skip Abstract Section

Abstract

Many language designers have adopted gradual typing. However, there remains open questions regarding how to gradualize languages. Cimini and Siek (2016) created a methodology and algorithm to automatically generate the type system of a gradually typed language from a fully static version of the language. In this paper, we address the next challenge of how to automatically generate the dynamic semantics of gradually typed languages. Such languages typically use an intermediate language with explicit casts.

Our first result is a methodology for generating the syntax, type system, and dynamic semantics of the intermediate language with casts. Next, we present an algorithm that formalizes and automates the methodology, given a language definition as input. We show that our approach is general enough to automatically gradualize several languages, including features such as polymorphism, recursive types and exceptions. We prove that our algorithm produces languages that satisfy the key correctness criteria of gradual typing. Finally, we implement the algorithm, generating complete specifications of gradually typed languages in lambda-Prolog, including executable interpreters.

References

  1. Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. Blame for all. In Proceedings of the 38th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’11, pages 201–214, New York, NY, USA, 2011. ACM. ISBN 978-1-4503-0490-0.Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Roberto M. Amadio and Luca Cardelli. Subtyping recursive types. In Proceedings of the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’91, pages 104–118, New York, NY, USA, 1991. ACM. ISBN 0-89791-419-8. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. David Baelde, Kaustuv Chaudhuri, Andrew Gacek, Dale Miller, Gopalan Nadathur, Alwen Tiu, and Yuting Wang. Abella: A system for reasoning about relational specifications. Journal of Formalized Reasoning, 7(2), 2014.Google ScholarGoogle Scholar
  4. Gavin Bierman, Mart´ın Abadi, and Mads Torgersen. Understanding TypeScript. In Richard Jones, editor, ECOOP 2014 – Object-Oriented Programming, volume 8586 of Lecture Notes in Computer Science, pages 257–281. Springer Berlin Heidelberg, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Matteo Cimini and Jeremy G. Siek. The gradualizer: a methodology and algorithm for generating gradual type systems. In Symposium on Principles of Programming Languages, POPL, January 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Benjamin Delaware, Bruno C. d. S. Oliveira, and Tom Schrijvers. Meta-theory à la carte. In Proceedings of the 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’13, pages 207–218, New York, NY, USA, 2013. ACM. ISBN 978-1-4503-1832-7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Robert Bruce Findler and Matthias Felleisen. Contracts for higherorder functions. Technical Report NU-CCS-02-05, Northeastern University, 2002.Google ScholarGoogle Scholar
  8. Robert Bruce Findler, Matthew Flatt, and Matthias Felleisen. Contracts for higher-order functions. In International Conference on Functional Programming, ICFP, pages 48–59, October 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Robert Bruce Findler, Matthew Flatt, and Matthias Felleisen. Semantic casts: Contracts and structural subtyping in a nominal world. In European Conference on Object-Oriented Programming, 2004.Google ScholarGoogle Scholar
  10. Cormac Flanagan. Hybrid type checking. In POPL 2006: The 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 245–256, Charleston, South Carolina, January 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Ronal Garcia, Alison M. Clark, and Éric Tanter. Abstracting gradual typing. In Proceedings of the 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, St Petersburg, FL, USA, January 20-22. ACM Press, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Álvaro Garc´ıa-Pérez, Pablo Nogueira, and Ilya Sergey. Deriving interpretations of the gradually-typed lambda calculus. In Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation, PEPM ’14, pages 157–168, New York, NY, USA, 2014. ACM. ISBN 978-1-4503-2619-3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Robert Harper. Practical Foundations for Programming Languages. Cambridge University Press, New York, NY, USA, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. ISBN 1107029570, 9781107029576.Google ScholarGoogle Scholar
  15. Anders Hejlsberg. C# 4.0 and beyond. Microsoft Channel 9 Blog, April 2010.Google ScholarGoogle Scholar
  16. Anders Hejlsberg. Introducing TypeScript. Microsoft Channel 9 Blog, 2012.Google ScholarGoogle Scholar
  17. David Herman, Aaron Tomb, and Cormac Flanagan. Space-efficient gradual typing. In Trends in Functional Prog. (TFP), page XXVIII, April 2007.Google ScholarGoogle Scholar
  18. David Herman, Aaron Tomb, and Cormac Flanagan. Space-efficient gradual typing. Higher-Order and Symbolic Computation, 23(2):167– 189, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. Featherweight java: a minimal core calculus for java and gj. ACM Transactions on Programming Languages and Systems, 23(3):396–450, 2001. ISSN 0164-0925. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Matthias Keil and Peter Thiemann. Transparent object proxies in javascript. In European Conference on Object-Oriented Programming, 2015.Google ScholarGoogle Scholar
  21. Nicolás Lehmann and Éric Tanter. Gradual refinement types. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, Fr, January 18-20. ACM Press, 2017. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. Dynamic typing with dependent types (extended abstract). In 3rd IFIP International Conference on Theoretical Computer Science, August 2004.Google ScholarGoogle Scholar
  23. Christopher Schwaab and Jeremy G. Siek. Modular type-safety proofs in agda. In Proceedings of the 7th Workshop on Programming Languages Meets Program Verification, PLPV ’13, pages 3–12, New York, NY, USA, 2013. ACM. ISBN 978-1-4503-1860-0. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Jeremy G. Siek and Ronald Garcia. Interpretations of the graduallytyped lambda calculus. In Scheme and Functional Programming Workshop, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Jeremy G. Siek and Walid Taha. Gradual typing for functional languages. In Scheme and Functional Programming Workshop, pages 81–92, September 2006.Google ScholarGoogle Scholar
  26. Jeremy G. Siek and Philip Wadler. Threesomes, with and without blame. In Proceedings for the 1st workshop on Script to Program Evolution, STOP ’09, pages 34–46, New York, NY, USA, 2009. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Jeremy G. Siek and Philip Wadler. Threesomes, with and without blame. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’10, pages 365–376, New York, NY, USA, 2010. ACM. ISBN 978-1- 60558-479-9. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Jeremy G. Siek, Peter Thiemann, and Philip Wadler. Blame and coercion: Together again for the first time. In Conference on Programming Language Design and Implementation, PLDI, June 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. Refined criteria for gradual typing. In SNAPL: Summit on Advances in Programming Languages, LIPIcs: Leibniz International Proceedings in Informatics, May 2015.Google ScholarGoogle Scholar
  30. The Dart Team. Dart Programming Language Specification. Google, 1.2 edition, March 2014.Google ScholarGoogle Scholar
  31. Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage migration: From scripts to programs. In Dynamic Languages Symposium, 2006.Google ScholarGoogle Scholar
  32. Sam Tobin-Hochstadt and Matthias Felleisen. The design and implementation of Typed Scheme. In Symposium on Principles of Programming Languages, January 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Tom Van Cutsem and Mark S. Miller. Proxies: Design principles for robust object-oriented intercession apis. In Proceedings of the 6th Symposium on Dynamic Languages, DLS ’10, pages 59–72, New York, NY, USA, 2010. ACM. ISBN 978-1-4503-0405-4. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Julien Verlaguet. Facebook: Analyzing PHP statically. In Commercial Users of Functional Programming (CUFP), 2013.Google ScholarGoogle Scholar
  35. Michael M. Vitousek, Andrew M. Kent, Jeremy G. Siek, and Jim Baker. Design and evaluation of gradual typing for Python. In Symposium on Dynamic Languages, DLS ’14, pages 1–16, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Philip Wadler and Robert Bruce Findler. Well-typed programs can’t be blamed. In Workshop on Scheme and Functional Programming, pages 15–26, 2007.Google ScholarGoogle Scholar
  37. Philip Wadler and Robert Bruce Findler. Well-typed programs can’t be blamed. In European Symposium on Programming, ESOP, pages 1–16, March 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Tobias Wrigstad, Francesco Zappa Nardelli, Sylvain Lebresne, Johan Östlund, and Jan Vitek. Integrating typed and untyped code in a scripting language. In Symposium on Principles of Programming Languages, POPL, pages 377–388, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Automatically generating the dynamic semantics of gradually typed languages

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 52, Issue 1
        POPL '17
        January 2017
        901 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3093333
        Issue’s Table of Contents
        • cover image ACM Conferences
          POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages
          January 2017
          901 pages
          ISBN:9781450346603
          DOI:10.1145/3009837

        Copyright © 2017 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 1 January 2017

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!