Reference. Is Sound Gradual Typing Dead?

Programmers have come to embrace dynamically-typed languages for prototyping and delivering large and complex systems. When it comes to maintaining and evolving these systems, the lack of explicit static typing becomes a bottleneck. In response, researchers have explored the idea of gradually-typed programming languages which allow the incremental addition of type annotations to software written in one of these untyped languages. Some of these new, hybrid languages insert run-time checks at the boundary between typed and untyped code to establish type soundness for the overall system. With sound gradual typing, programmers can rely on the language implementation to provide meaningful error messages when type invariants are violated. While most research on sound gradual typing remains theoretical, the few emerging implementations suffer from performance overheads due to these checks. None of the publications on this topic comes with a comprehensive performance evaluation. Worse, a few report disastrous numbers. In response, this paper proposes a method for evaluating the performance of gradually-typed programming languages. The method hinges on exploring the space of partial conversions from untyped to typed. For each benchmark, the performance of the different versions is reported in a synthetic metric that associates runtime overhead to conversion effort. The paper reports on the results of applying the method to Typed Racket, a mature implementation of sound gradual typing, using a suite of real-world programs of various sizes and complexities. Based on these results the paper concludes that, given the current state of implementation technologies, sound gradual typing faces significant challenges. Conversely, it raises the question of how implementations could reduce the overheads associated with soundness and how tools could be used to steer programmers clear from pathological cases.

Cite

Cite as @takikawa_etal_2016 (helia, typst) · \cite{takikawa_etal_2016} (LaTeX)
BibTeX
bibtex · 8 lines
@inproceedings{takikawa_etal_2016,
 title = {Is Sound Gradual Typing Dead?},
 author = {Takikawa, Asumu and Feltey, Daniel and Greenman, Ben and New, Max S. and Vitek, Jan and Felleisen, Matthias},
 year = {2016},
 url = {http://dl.acm.org/citation.cfm?id=2837630},
 booktitle = {Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016},
 publisher = {ACM}
}
hayagriva YAML (typst)
yaml · 16 lines
takikawa_etal_2016:
  type: article
  title: Is Sound Gradual Typing Dead?
  author:
  - Takikawa, Asumu
  - Feltey, Daniel
  - Greenman, Ben
  - New, Max S.
  - Vitek, Jan
  - Felleisen, Matthias
  date: 2016
  url: http://dl.acm.org/citation.cfm?id=2837630
  parent:
    type: proceedings
    title: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016
    publisher: ACM
Cited by (4)

Gradual Typing for Effect Handlers new_giovannini_licata_2023

We present a gradually typed language, GrEff, with effects and handlers that supports migration from unchecked to checked effect typing. This serves as a simple model of the integration of an effect typing discipline with an existing effectful typed language that does not track fine-grained effect information. Our language supports a simple module system to model the programming model of gradual migration from unchecked to checked effect typing in the style of Typed Racket.

The surface language GrEff is given semantics by elaboration to a core language Core GrEff. We equip Core GrEff with an inequational theory for reasoning about the semantic error ordering and desired program equivalences for programming with effects and handlers. We derive an operational semantics for the language from the equations provable in the theory. We then show that the theory is sound by constructing an operational logical relations model to prove the graduality theorem. This extends prior work on embedding-projection pair models of gradual typing to handle effect typing and subtyping.

PDF · Web · pldb

Gradual Type Theory new_licata_ahmed_2021

Gradually typed languages are designed to support both dynamically typed and statically typed programming styles while preserving the benefits of each. Sound gradually typed languages dynamically check types at runtime at the boundary between statically typed and dynamically typed modules. However, there is much disagreement in the gradual typing literature over how to enforce complex types such as tuples, lists, functions and objects. In this paper, we propose a new perspective on the design of runtime gradual type enforcement: runtime type casts exist precisely to ensure the correctness of certain type-based refactorings and optimizations. For instance, for simple types, a language designer might desire that beta-eta equality is valid. We show that this perspective is useful by demonstrating that a cast semantics can be derived from beta-eta equality. We do this by providing an axiomatic account program equivalence in a gradual cast calculus in a logic we call gradual type theory (GTT). Based on Levy’s call-by-push-value, GTT allows us to axiomatize both call-by-value and call-by-name gradual languages. We then show that we can derive the behavior of casts for simple types from the corresponding eta equality principle and the assumption that the language satisfies a property called graduality, also known as the dynamic gradual guarantee. Since we can derive the semantics from the assumption of eta equality, we also receive a useful contrapositive: any observably different cast semantics that satisfies graduality must violate the eta equality. We show the consistency and applicability of our axiomatic theory by proving that a contract-based implementation using the lazy cast semantics gives a logical relations model of our type theory, where equivalence in GTT implies contextual equivalence of the programs. Since GTT also axiomatizes the dynamic gradual guarantee, our model also establishes this central theorem of gradual typing. The model is parameterized by the implementation of the dynamic types, and so gives a family of implementations that validate type-based optimization and the gradual guarantee.
PDF · DOI · pldb

A Semantic Foundation for Sound Gradual Typing new_dissertation_2020

Gradually typed programming languages provide a way forward in the debate between static and dynamic typing. In a gradual language, statically typed and dynamically typed programs can intermingle, and dynamically typed scripts can be gradually migrated to a statically typed style. In a sound gradually typed language, static type information is just as reliable as in a static language, establishing correctness of type-based refactoring and optimization. To ensure this in the presence of dynamic typing, runtime type casts are inserted automatically at the boundary between static and dynamic code. However the design of these languages is somewhat ad hoc, with little guidance on how to ensure that static reasoning principles are valid. In my dissertation, I present a semantic framework for design and metatheoretic analysis of gradually typed languages based on the theory of embedding-projection pairs. I show that this semantics enables proofs of the fundamental soundness theorems of gradual typing, and that it is robust, applying it to different evaluation orders and programming features.
Web

How to evaluate the performance of gradual type systems greenman_etal_2019

A sound gradual type system ensures that untyped components of a program can never break the guarantees of statically typed components. This assurance relies on runtime checks, which in turn impose performance overhead in proportion to the frequency and nature of interaction between typed and untyped components. The literature on gradual typing lacks rigorous descriptions of methods for measuring the performance of gradual type systems. This gap has consequences for the implementors of gradual type systems and developers who use such systems. Without systematic evaluation of mixed-typed programs, implementors cannot precisely determine how improvements to a gradual type system affect performance. Developers cannot predict whether adding types to part of a program will significantly degrade (or improve) its performance. This paper presents the first method for evaluating the performance of sound gradual type systems. The method quantifies both the absolute performance of a gradual type system and the relative performance of two implementations of the same gradual type system. To validate the method, the paper reports on its application to 20 programs and 3 implementations of Typed Racket.
PDF · DOI · pldb
Cites 28 works (0 here)
External (28)
  • Pycket: A Tracing JIT For a Functional Language (2015)
  • Safe & Efficient Gradual Typing for TypeScript (2015)
  • Concrete Types for TypeScript (2015)
  • Feature-specific Profiling (2015)
  • Towards Practical Gradual Typing (2015)
  • Confined Gradual Typing (2014)
  • Typed Lua: An Optional Type System for Lua (2014)
  • Soft Contract Verification (2014)
  • Design and Evaluation of Gradual Typing for Python (2014)
  • Gradual typing for Smalltalk (2013)
  • Cast Insertion Strategies for Gradually-Typed Objects (2013)
  • A Practical Optional Type System for Clojure (2012)
  • The Impact of Optional Type Information on JIT Compilation of Dynamically Typed Languages (2011)
  • Languages as Libraries (2011)
  • Threesomes, with and without blame (2010)
  • Integrating Typed and Untyped Code in a Scripting Language (2010)
  • Thorn: Robust, Concurrent, Extensible Scripting on the JVM (2009)
  • Practical Pluggable Types for Java (2008)
  • Gradual Typing for Functional Languages (2006)
  • Interlanguage Migration: from Scripts to Programs (2006)
  • Pluggable Type Systems (2004)
  • Contracts for Higher-Order Functions (2002)
  • Safe Polymorphic Type Inference for a Dynamically Typed Language: Translating Scheme to ML (1995)
  • A Syntactic Approach to Type Soundness (1994)
  • Strongtalk: Typechecking Smalltalk in a Production Environment (1993)
  • Dynamic Typing in a Statically Typed Language (1991)
  • MACLISP Reference Manual (1974)
  • The Methodology of Evaluation (1967)
takikawa_etal_2016 reference entries/refs/takikawa_etal_2016/takikawa_etal_2016.hel