Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Gradually Typed Languages Should Be Vigilant!

Published: 29 April 2024 Publication History
  • Get Citation Alerts
  • Abstract

    In gradual typing, different languages perform different dynamic type checks for the same program even though the languages have the same static type system. This raises the question of whether, given a gradually typed language, the combination of the translation that injects checks in well-typed terms and the dynamic semantics that determines their behavior sufficiently enforce the static type system of the language. Neither type soundness, nor complete monitoring, nor any other meta-theoretic property of gradually typed languages to date provides a satisfying answer.
    In response, we present vigilance, a semantic analytical instrument that defines when the check-injecting translation and dynamic semantics of a gradually typed language are adequate for its static type system. Technically, vigilance asks if a given translation-and-semantics combination enforces the complete run-time typing history of a value, which consists of all of the types associated with the value. We show that the standard combination for so-called Natural gradual typing is vigilant for the standard simple type system, but the standard combination for Transient gradual typing is not. At the same time, the standard combination for Transient is vigilant for a tag type system but the standard combination for Natural is not. Hence, we clarify the comparative type-level reasoning power between the two most studied approaches to sound gradual typing. Furthermore, as an exercise that demonstrates how vigilance can guide design, we introduce and examine a new theoretical static gradual type system, dubbed truer, that is stronger than tag typing and more faithfully reflects the type-level reasoning power that the dynamic semantics of Transient gradual typing can guarantee.

    Supplementary Material

    Auxiliary Archive (oopslaa24main-p120-p-archive.zip)
    Technical Appendix for Gradually Typed Languages Should Be Vigilant!

    References

    [1]
    Amal Ahmed. 2006. Step-indexed syntactic logical relations for recursive and quantified types. In European Symposium on Programming. 69–83. https://doi.org/10.1007/11693024_6
    [2]
    Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. 2011. Blame for All. In Proceedings of the 38th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’11). Association for Computing Machinery, New York, NY, USA. 201–214. isbn:9781450304900 https://doi.org/10.1145/1926385.1926409
    [3]
    Amal Ahmed, Dustin Jamner, Jeremy G. Siek, and Philip Wadler. 2017. Theorems for free for free: parametricity, with and without types. Proc. ACM Program. Lang., 1, ICFP (2017), Article 39, aug, 28 pages. https://doi.org/10.1145/3110283
    [4]
    Amal Jamil Ahmed. 2004. Semantics of Types for Mutable State. Ph. D. Dissertation. USA. https://dl.acm.org/doi/10.5555/1037736
    [5]
    Andrew W. Appel and David McAllester. 2001. An Indexed Model of Recursive Types for Foundational Proof-Carrying Code. ACM Trans. Program. Lang. Syst., 23, 5 (2001), sep, 657–683. issn:0164-0925 https://doi.org/10.1145/504709.504712
    [6]
    Felipe Bañados Schwerter, Alison M. Clark, Khurram A. Jafery, and Ronald Garcia. 2021. Abstracting Gradual Typing Moving Forward: Precise and Space-Efficient. Proc. ACM Program. Lang., 5, POPL (2021), Article 61, jan, 28 pages. https://doi.org/10.1145/3434342
    [7]
    Avik Chaudhuri, Panagiotis Vekris, Sam Goldman, Marshall Roch, and Gabriel Levy. 2017. Fast and Precise Type Checking for JavaScript. Proc. ACM Program. Lang., 1, OOPSLA (2017), 56:1–56:30. https://doi.org/10.1145/3133872
    [8]
    Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Complete Monitors for Behavioral Contracts. In European Symposium on Programming. https://doi.org/10.1007/978-3-642-28869-2_11
    [9]
    Daniel Feltey, Ben Greenman, Christophe Scholliers, Robert Bruce Findler, and Vincent St-Amour. 2018. Collapsible Contracts: Fixing a Pathology of Gradual Typing. 2, OOPSLA (2018), 133:1–133:27. https://doi.org/10.1145/3276503
    [10]
    Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In ACM SIGPLAN Symposium on Principles of Programming Languages. 429–442. https://doi.org/10.1145/2837614.2837670
    [11]
    Michael Greenberg. 2015. Space-Efficient Manifest Contracts. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 181–194. https://doi.org/10.1145/2676726.2676967
    [12]
    Ben Greenman. 2022. Deep and shallow types for gradual languages. In PLDI. 580–593. https://doi.org/10.1145/3519939.3523430
    [13]
    Ben Greenman, Christos Dimoulas, and Matthias Felleisen. 2023. Typed–Untyped Interactions: A Comparative Analysis. ACM Trans. Program. Lang. Syst., 45, 1 (2023), Article 4, mar, 54 pages. issn:0164-0925 https://doi.org/10.1145/3579833
    [14]
    Ben Greenman and Matthias Felleisen. 2018. A Spectrum of Type Soundness and Performance. 2, ICFP (2018), 71:1–71:32. https://doi.org/10.1145/3235045
    [15]
    Ben Greenman, Matthias Felleisen, and Christos Dimoulas. 2019. Complete Monitors for Gradual Types. PACMPL, 3, OOPSLA (2019), 122:1–122:29. https://doi.org/10.1145/3360548
    [16]
    Ben Greenman, Lukas Lazarek, Christos Dimoulas, and Matthias Felleisen. 2022. A Transient Semantics for Typed Racket. Art Sci. Eng. Program., 6, 2 (2022), 9. https://doi.org/10.22152/programming-journal.org/2022/6/9
    [17]
    Ben Greenman, Asumu Takikawa, Max S. New, Daniel Feltey, Robert Bruce Findler, Jan Vitek, and Matthias Felleisen. 2019. How to Evaluate the Performance of Gradual Typing Systems. 29, e4 (2019), https://doi.org/10.1017/S0956796818000217
    [18]
    David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-efficient gradual typing. Higher Order Symbol. Comput., 23, 2 (2010), jun, 167–189. issn:1388-3690 https://doi.org/10.1007/s10990-011-9066-z
    [19]
    Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017. On Polymorphic Gradual Typing. Proc. ACM Program. Lang., 1, ICFP (2017), 40:1–40:29. https://doi.org/10.1145/3110284
    [20]
    Koen Jacobs, Amin Timany, and Dominique Devriese. 2021. Fully Abstract from Static to Gradual. Proc. ACM Program. Lang., 5, POPL (2021), Article 7, jan, 30 pages. https://doi.org/10.1145/3434288
    [21]
    Andre Kuhlenschmidt, Deyaaeldeen Almahallawi, and Jeremy G. Siek. 2019. Toward Efficient Gradual Typing for Structural Types via Coercions. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2019). Association for Computing Machinery, New York, NY, USA. 517–532. isbn:9781450367127 https://doi.org/10.1145/3314221.3314627
    [22]
    Lukas Lazarek, Ben Greenman, Matthias Felleisen, and Christos Dimoulas. 2021. How to Evaluate Blame for Gradual Types. 5, ICFP (2021), 68:1–68:29. https://doi.org/10.1145/3473573
    [23]
    Lukas Lazarek, Ben Greenman, Matthias Felleisen, and Christos Dimoulas. 2023. How to Evaluate Blame for Gradual Types, Part 2. 7, ICFP (2023), 159–186. https://doi.org/10.1145/3607836
    [24]
    Jacob Matthews and Robert Bruce Findler. 2009. Operational Semantics for Multi-Language Programs. ACM Trans. Program. Lang. Syst., 31, 3 (2009), Article 12, apr, 44 pages. issn:0164-0925 https://doi.org/10.1145/1498926.1498930
    [25]
    Fabian Muehlboeck and Ross Tate. 2017. Sound Gradual Typing is Nominally Alive and Well. Proc. ACM Program. Lang., 1, OOPSLA (2017), 56:1–56:30. https://doi.org/10.1145/3133880
    [26]
    Max S. New, Daniel R. Licata, and Amal Ahmed. 2019. Gradual Type Theory. 3, POPL (2019), 15:1 — 15:31. https://doi.org/10.1145/3290328
    [27]
    Max S. New, Daniel R. Licata, and Amal Ahmed. 2021. Gradual type theory. Journal of Functional Programming, 31 (2021), e21. https://doi.org/10.1017/S0956796821000125
    [28]
    Susan Owicki and David Gries. 1976. Verifying Properties of Parallel Programs: An Axiomatic Approach. Commun. ACM, 19, 5 (1976), may, 279–285. issn:0001-0782 https://doi.org/10.1145/360051.360224
    [29]
    Andrew Pitts and Ian Stark. 1998. Operational Reasoning for Functions with Local State. In Higher Order Operational Techniques in Semantics, Andrew Gordon and Andrew Pitts (Eds.). Publications of the Newton Institute, Cambridge University Press, 227–273. http://www.inf.ed.ac.uk/~stark/operfl.html
    [30]
    Uday S. Reddy and Hongseok Yang. 2003. Correctness of Data Representations Involving Heap Data Structures. In Programming Languages and Systems, Pierpaolo Degano (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 223–237. isbn:978-3-540-36575-4 https://dl.acm.org/doi/10.5555/1765712.1765730
    [31]
    Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Proceedings of the 2006 Workshop on Scheme and Functional Programming Workshop. 81–92. http://scheme2006.cs.uchicago.edu/13-siek.pdf
    [32]
    Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In 1st Summit on Advances in Programming Languages (SNAPL 2015), Thomas Ball, Rastislav Bodik, Shriram Krishnamurthi, Benjamin S. Lerner, and Greg Morrisett (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 32). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 274–293. isbn:978-3-939897-80-4 issn:1868-8969 https://doi.org/10.4230/LIPIcs.SNAPL.2015.274
    [33]
    Jeremy G Siek, Michael M Vitousek, Matteo Cimini, Sam Tobin-Hochstadt, and Ronald Garcia. 2015. Monotonic references for efficient gradual typing. In Programming Languages and Systems: 24th European Symposium on Programming, ESOP 2015, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2015, London, UK, April 11-18, 2015, Proceedings 24. 432–456. https://doi.org/10.1007/978-3-662-46669-8_18
    [34]
    Jeremy G. Siek and Philip Wadler. 2010. Threesomes, with and without blame. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’10). Association for Computing Machinery, New York, NY, USA. 365–376. isbn:9781605584799 https://doi.org/10.1145/1706299.1706342
    [35]
    Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage Migration: from Scripts to Programs. In Dynamic Languages Symposium. 964–974. https://doi.org/10.1145/1176617.1176755
    [36]
    Matías Toro, Elizabeth Labrada, and Éric Tanter. 2019. Gradual Parametricty, Revisited. Proc. ACM Program. Lang., 3, POPL (2019), 17:1–17:30. https://doi.org/10.1145/3290330
    [37]
    Michael M. Vitousek, Jeremy G. Siek, and Avik Chaudhuri. 2019. Optimizing and Evaluating Transient Gradual Typing. In Proceedings of the 15th ACM SIGPLAN International Symposium on Dynamic Languages (DLS 2019). Association for Computing Machinery, New York, NY, USA. 28–41. isbn:9781450369961 https://doi.org/10.1145/3359619.3359742
    [38]
    Michael M. Vitousek, Cameron Swords, and Jeremy G. Siek. 2017. Big Types in Little Runtime: Open-World Soundness and Collaborative Blame for Gradual Type Systems. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL ’17). Association for Computing Machinery, New York, NY, USA. 762–774. isbn:9781450346603 https://doi.org/10.1145/3009837.3009849
    [39]
    Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’t Be Blamed. In Proceedings of the 18th European Symposium on Programming Languages and Systems: Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2009 (ESOP ’09). Springer-Verlag, Berlin, Heidelberg. 1–16. isbn:9783642005893 https://doi.org/10.1007/978-3-642-00590-9_1

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 8, Issue OOPSLA1
    April 2024
    1492 pages
    EISSN:2475-1421
    DOI:10.1145/3554316
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution International 4.0 License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 29 April 2024
    Published in PACMPL Volume 8, Issue OOPSLA1

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. gradual typing
    2. logical relations
    3. natural
    4. semantics
    5. transient

    Qualifiers

    • Research-article

    Funding Sources

    • NSF Career Award Christos Dimoulas
    • NSF SHF: Semantic Foundations for Gradual Typing
    • DARPA V-SPELLS: POLYMORPH: Promotion to Optimal Languages Yielding Modular Operator-Driven Replacements and Programmatic Hooks

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 54
      Total Downloads
    • Downloads (Last 12 months)54
    • Downloads (Last 6 weeks)23

    Other Metrics

    Citations

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media