Combining Static and Dynamic Typing in Ruby
نویسنده
چکیده
Title of dissertation: Combining Static and Dynamic Typing in Ruby Michael Furr Doctor of Philosophy, 2009 Dissertation directed by: Professor Jeffrey S. Foster Department of Computer Science Many popular scripting languages such as Ruby, Python, and Perl are dynamically typed. Dynamic typing provides many advantages such as terse, flexible code and the ability to use highly dynamic language constructs, such as an eval method that evaluates a string as program text. However these dynamic features have traditionally obstructed static analyses leaving the programmer without the benefits of static typing, including early error detection and the documentation provided by type annotations. In this dissertation, we present Diamondback Ruby (DRuby), a tool that blends static and dynamic typing for Ruby. DRuby provides a type language that is rich enough to precisely type Ruby code, without unneeded complexity. DRuby uses static type inference to automatically discover type errors in Ruby programs and provides a type annotation language that serves as verified documentation of a method’s behavior. When necessary, these annotations can be checked dynamically using runtime contracts. This allows statically and dynamically checked code to safely coexist, and any runtime errors are properly blamed on dynamic code. To handle dynamic features such as eval, DRuby includes a novel dynamic analysis and transformation that gathers per-application profiles of dynamic feature usage via a program’s test suite. Based on these profiles, DRuby transforms the program before applying its type inference algorithm, enforcing type safety for dynamic constructs. By leveraging a program’s test suite, our technique gives the programmer an easy to understand trade-off: the more dynamic features covered by their tests, the more static checking is achieved. We evaluated DRuby on a benchmark suite of sample Ruby programs. We found that our profile-guided analysis and type inference algorithms worked well, discovering several previously unknown type errors. Furthermore, our results give us insight into what kind of Ruby code programmers “want” to write but is not easily amenable to traditional static typing. This dissertation shows that it is possible to effectively integrate static typing into Ruby without losing the feel of a dynamic language. Combining Static and Dynamic Typing in Ruby
منابع مشابه
Tests to the Left of Me, Types to the Right How Not to Get Stuck in the Middle of a Ruby Execution (A Demo of Diamondback Ruby)
Ruby is a popular dynamic scripting language that permits terse, expressive code, but provides no static checks to detect errors before running the program. To address this, we have developed Diamondback Ruby (DRuby), a tool that blends the benefits of static and dynamic typing. This paper briefly describes the main features of DRuby, which we will present in a tool demonstration. The presentat...
متن کاملType Systems of Scripting Languages
Type systems play an important role in the design of programming languages, they prevent programs from having non-correct behavior. Typically, type systems are expressed in two ways, type-checking and type inference. The type information presented on local variables and method arguments makes the difference in choosing one technique rather than the other. Type checking is a derivation type infe...
متن کاملRock typing and reservoir zonation based on the NMR logging and geological attributes in the mixed carbonate-siliciclastic Asmari Reservoir
Rock typing is known as the best way in heterogeneous reservoirs characterization. The rock typing methods confine to various aspects of the rocks such as multi-scale and multi-modal pore types and size, rock texture, diagenetic modifications and integration of static/dynamic data. Integration of static and dynamic behavior of rocks and their sedimentary features are practiced in this study. Po...
متن کاملWork In Progress: an Empirical Study of Static Typing in Ruby
In this paper, we present an empirical pilot study of four skilled programmers as they develop programs in Ruby, a popular, dynamically typed, object-oriented scripting language. Our study compares programmer behavior under the standard Ruby interpreter versus using Diamondback Ruby (DRuby), which adds static type inference to Ruby. The aim of our study is to understand whether DRuby’s static t...
متن کاملTypes for Dynamic Reconfiguration
We define a core language combining computational and architectural primitives, and study how static typing may be used to ensure safety properties of component composition and dynamic reconfiguration in object-based systems. We show how our language can model typed entities analogous of configuration scripts, makefiles, components, and component instances, where static typing combined with a d...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2009