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 等动态语言有许多令人信服的好处,但缺乏静态类型意味着在代码中隐蔽的微妙错误可能长期存在。虽然许多研究人员已经开发了各种系统,将静态类型的一些好处带给动态语言,但先前的方法在处理元程序设置代码方面有困难。在本文中,我们提议蜂鸟,这是一个使用新颖技术的新系统,即即时静态类型检查,以输入鲁比代码,即使存在元程序化。在蜂鸟中,方法型号的签名可以在运行时动态代码中继续隐藏。在创建这些方法时,方法会动态地收集。当一种方法被使用时,蜂鸟静型对方法体进行测试,以动态格式进行彻底的静态检查,同时允许任意复杂的元程序设置。对于性功能,蜂鸟对静态类型检查进行记录,即使是在出现元程序设置时也无效。在运行时,我们用核心、 Ruby 语言在运行时会自动收集, 证明它是否正常运行, 我们用 Hprimal 格式来评估 Hdrimal 。

0
下载
关闭预览

相关内容

Ruby 是一种面向对象、命令式、函数式、动态的通用编程语言。
知识图谱推理,50页ppt,Salesforce首席科学家Richard Socher
专知会员服务
109+阅读 · 2020年6月10日
因果图,Causal Graphs,52页ppt
专知会员服务
248+阅读 · 2020年4月19日
《DeepGCNs: Making GCNs Go as Deep as CNNs》
专知会员服务
31+阅读 · 2019年10月17日
强化学习最新教程,17页pdf
专知会员服务
177+阅读 · 2019年10月11日
[综述]深度学习下的场景文本检测与识别
专知会员服务
78+阅读 · 2019年10月10日
机器学习入门的经验与建议
专知会员服务
94+阅读 · 2019年10月10日
Transferring Knowledge across Learning Processes
CreateAMind
28+阅读 · 2019年5月18日
CCF A类 | 顶级会议RTSS 2019诚邀稿件
Call4Papers
10+阅读 · 2019年4月17日
Call for Participation: Shared Tasks in NLPCC 2019
中国计算机学会
5+阅读 · 2019年3月22日
Unsupervised Learning via Meta-Learning
CreateAMind
42+阅读 · 2019年1月3日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
17+阅读 · 2018年12月24日
Disentangled的假设的探讨
CreateAMind
9+阅读 · 2018年12月10日
利用动态深度学习预测金融时间序列基于Python
量化投资与机器学习
18+阅读 · 2018年10月30日
暗通沟渠:Multi-lingual Attention
我爱读PAMI
7+阅读 · 2018年2月24日
条件GAN重大改进!cGANs with Projection Discriminator
CreateAMind
8+阅读 · 2018年2月7日
Adversarial Variational Bayes: Unifying VAE and GAN 代码
CreateAMind
7+阅读 · 2017年10月4日
Arxiv
3+阅读 · 2018年3月2日
Arxiv
3+阅读 · 2017年12月18日
Arxiv
5+阅读 · 2017年11月30日
Arxiv
3+阅读 · 2015年5月16日
VIP会员
相关VIP内容
知识图谱推理,50页ppt,Salesforce首席科学家Richard Socher
专知会员服务
109+阅读 · 2020年6月10日
因果图,Causal Graphs,52页ppt
专知会员服务
248+阅读 · 2020年4月19日
《DeepGCNs: Making GCNs Go as Deep as CNNs》
专知会员服务
31+阅读 · 2019年10月17日
强化学习最新教程,17页pdf
专知会员服务
177+阅读 · 2019年10月11日
[综述]深度学习下的场景文本检测与识别
专知会员服务
78+阅读 · 2019年10月10日
机器学习入门的经验与建议
专知会员服务
94+阅读 · 2019年10月10日
相关资讯
Transferring Knowledge across Learning Processes
CreateAMind
28+阅读 · 2019年5月18日
CCF A类 | 顶级会议RTSS 2019诚邀稿件
Call4Papers
10+阅读 · 2019年4月17日
Call for Participation: Shared Tasks in NLPCC 2019
中国计算机学会
5+阅读 · 2019年3月22日
Unsupervised Learning via Meta-Learning
CreateAMind
42+阅读 · 2019年1月3日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
17+阅读 · 2018年12月24日
Disentangled的假设的探讨
CreateAMind
9+阅读 · 2018年12月10日
利用动态深度学习预测金融时间序列基于Python
量化投资与机器学习
18+阅读 · 2018年10月30日
暗通沟渠:Multi-lingual Attention
我爱读PAMI
7+阅读 · 2018年2月24日
条件GAN重大改进!cGANs with Projection Discriminator
CreateAMind
8+阅读 · 2018年2月7日
Adversarial Variational Bayes: Unifying VAE and GAN 代码
CreateAMind
7+阅读 · 2017年10月4日
Top
微信扫码咨询专知VIP会员