Treffer: Type Checking and Inference for Dynamic Languages

Title:
Type Checking and Inference for Dynamic Languages
Authors:
Publisher Information:
University of Maryland (College Park, Md.) 2019
Added Details:
Foster, Jeffrey S
Document Type:
E-Ressource Electronic Resource
Availability:
Open access content. Open access content
Note:
application/pdf
English
Other Numbers:
UMC oai:drum.lib.umd.edu:1903/25384
https://doi.org/10.13016/dvey-84hk
1152098418
Contributing Source:
UNIV OF MARYLAND, COL PARK
From OAIster®, provided by the OCLC Cooperative.
Accession Number:
edsoai.on1152098418
Database:
OAIster

Weitere Informationen

Object-oriented dynamic languages such as Ruby, Python, and JavaScript provide rapid code development and a high degree of flexibility and agility to the programmer. Some of the their main features include dynamic typing and metaprogramming. In dynamic typing, programmers do not declare or cast types, and types are not known until run time. In addition, an object’s suitability is determined by its methods, as opposed to its class. Metaprogramming dynamically generates code as the program executes, which means that methods and classes can be added and modified at run-time. These features are powerful but lead to a major drawback of dynamic languages: the lack of static types means that type errors can remain latent long into the software development process or even into deployment, especially in the presence of metaprogramming. To bring the benefits of static types to dynamic languages, I present three pieces of work. First, I present the Ruby Type Checker (rtc), a tool that adds type check- ing to Ruby. Rtc addresses the issue of latent type errors by checking all types during run time at method entrance and exit. Thus it checks types later than a purely static system, but earlier than a traditional dynamic type system. Rtc is implemented as a Ruby library and supports type annotations on classes, methods, and objects. Rtc provides a rich type language that includes union and intersection types, higher-order (block) types, and parametric polymorphism, among other features. We applied rtc to several apps and found it effective at checking types. Second, I present Hummingbird, a just-in-time static type checker for dy- namic languages. Hummingbird also prevents latent type errors, and type checks Ruby code even in the presence of metaprogramming, which is not handled by rtc. In Hummingbird, method type signatures are gathered dynamically at run-time, as those methods are created. When a method is called, Hummingbird statically type checks the method body against curre