首页> 外文学位 >Combining static and dynamic typing in Ruby.
【24h】

Combining static and dynamic typing in Ruby.

机译:在Ruby中结合静态和动态类型。

获取原文
获取原文并翻译 | 示例

摘要

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.
机译:动态流行许多流行的脚本语言,例如Ruby,Python和Perl。动态类型提供许多优点,例如简洁,灵活的代码以及使用高度动态语言构造的能力,例如将字符串评估为程序文本的eval方法。但是,这些动态功能传统上阻碍了静态分析,从而使程序员无法享受静态类型化的好处,包括早期错误检测和类型注释提供的文档。在本文中,我们介绍了将静态和静态混合的工具Diamondback Ruby(DRuby)。 Ruby的动态类型。 DRuby提供了足够丰富的类型语言,可以精确地键入Ruby代码,而无需不必要的复杂性。 DRuby使用静态类型推断来自动发现Ruby程序中的类型错误,并提供了一种类型标注语言,该语言用作方法行为的经过验证的文档。必要时,可以使用运行时协定动态检查这些注释。这允许静态和动态检查的代码安全地共存,并且任何运行时错误都应归咎于动态代码。为了处理诸如eval之类的动态功能,DRuby包括一种新颖的动态分析和转换,可通过程序的测试套件收集每个应用程序对动态功能使用情况的配置文件。基于这些配置文件,DRuby在应用程序的类型推断算法之前对其进行转换,从而为动态构造增强了类型安全性。通过利用程序的测试套件,我们的技术为程序员提供了一个易于理解的折衷方案:测试覆盖的动态功能越多,实现的静态检查就越多。我们在示例Ruby程序的基准套件上评估了DRuby。我们发现,配置文件引导的分析和类型推断算法效果很好,发现了一些以前未知的类型错误。此外,我们的结果使我们能够洞悉要“编写”什么样的Ruby代码程序员,但是不容易接受传统的静态类型。本文表明,可以将静态类型有效地集成到Ruby中,而不会失去动态语言的感觉。

著录项

  • 作者

    Furr, Michael.;

  • 作者单位

    University of Maryland, College Park.;

  • 授予单位 University of Maryland, College Park.;
  • 学科 Computer Science.
  • 学位 Ph.D.
  • 年度 2009
  • 页码 212 p.
  • 总页数 212
  • 原文格式 PDF
  • 正文语种 eng
  • 中图分类
  • 关键词

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号