...
【24h】

Just-in-Time Static Type Checking for Dynamic Languages

机译:动态语言的即时静态类型检查

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

摘要

Dynamic languages such as Ruby, Python, and JavaScript have many compelling benefits, but the lack of static types means subtle errors can remain latent in code for a long time. While many researchers have developed various systems to bring some of the benefits of static types to dynamic languages, prior approaches have trouble dealing with metaprogramming, which generates code as the program executes. In this paper, we propose Hummingbird, a new system that uses a novel technique, just-in-time static type checking, to type check Ruby code even in the presence of metaprogramming. 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 current type signatures. Thus, Hummingbird provides thorough static checks on a per-method basis, while also allowing arbitrarily complex metaprogramming. For performance, Hummingbird memoizes the static type checking pass, invalidating cached checks only if necessary. We formalize Hummingbird using a core, Ruby-like language and prove it sound. To evaluate Hummingbird, we applied it to six apps, including three that use Ruby on Rails, a powerful framework that relies heavily on metaprogramming. We found that all apps typecheck successfully using Hummingbird, and that Hummingbird's performance overhead is reasonable. We applied Hummingbird to earlier versions of one Rails app and found several type errors that had been introduced and then fixed. Lastly, we demonstrate using Hummingbird in Rails development mode to typecheck an app as live updates are applied to it.
机译:诸如Ruby,Python和JavaScript之类的动态语言具有许多引人注目的好处,但是缺少静态类型意味着细微的错误可以在代码中长期保留。尽管许多研究人员开发了各种系统,以将静态类型的某些优点带给动态语言,但是现有方法难以处理元编程,元编程会在程序执行时生成代码。在本文中,我们提出了Hummingbird这个新系统,它使用一种新颖的技术(即时静态类型检查)来对Ruby代码进行类型检查,即使存在元编程也是如此。在Hummingbird中,创建方法时,将在运行时动态收集方法类型签名。调用方法时,Hummingbird会根据当前类型签名对类型进行静态检查。因此,蜂鸟基于方法提供了彻底的静态检查,同时还允许任意复杂的元编程。为了提高性能,Hummingbird记住静态类型检查过程,仅在必要时使缓存的检查无效。我们使用类似Ruby的核心语言对Hummingbird进行了形式化验证,并证明了它的正确性。为了评估Hummingbird,我们将其应用于六个应用程序,包括三个使用Ruby on Rails的应用程序,Ruby on Rails是一个功能强大的框架,严重依赖于元编程。我们发现所有应用程序都可以使用Hummingbird成功进行类型检查,并且Hummingbird的性能开销是合理的。我们将Hummingbird应用于一个Rails应用程序的早期版本,发现了一些已引入并已修复的类型错误。最后,我们演示了在Rails开发模式下使用Hummingbird对应用程序进行类型检查的过程。

著录项

相似文献

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

客服邮箱:kefu@zhangqiaokeyan.com

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

  • 服务号