arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1711.04559cs.PL
收藏

多语言软件的链接类型:鱼与熊掌兼得

Linking Types for Multi-Language Software: Have Your Cake and Eat It Too

Daniel Patterson, Amal Ahmed

摘要:

软件开发人员将用许多不同语言编写的组件组合成系统。业务逻辑组件可以用Java或OCaml编写,资源密集型组件用C或Rust编写,高保证组件用Coq编写。在这个多语言世界中,程序执行将值从一个语言上下文发送到另一个。这种边界交叉将值暴露给具有不可预见行为的上下文-即,在值的源语言中不可能出现的行为。例如,一个Rust函数可能最终被应用在ML上下文中,这违反了Rust类型系统强制执行的内存使用策略。这就引出了这样一个问题:在这样一个多语言的世界里,一种语言无法表达的行为在另一种语言中很容易实现,开发人员应该如何推理代码。本文提出了连接类型的新思想,以解决在多语言环境中的单语言组件的推理问题。具体地说,链接类型允许程序员注释程序中的哪些地方可以链接到他们的纯语言中无法表达的组件。这使得开发人员能够仅使用他们自己的语言和注释来推理(行为)相等性,即使他们的代码可能与用具有更强表达能力的语言编写的代码相链接。

英文摘要:

Software developers compose systems from components written in many different languages. A business-logic component may be written in Java or OCaml, a resource-intensive component in C or Rust, and a high-assurance component in Coq. In this multi-language world, program execution sends values from one linguistic context to another. This boundary-crossing exposes values to contexts with unforeseen behavior---that is, behavior that could not arise in the source language of the value. For example, a Rust function may end up being applied in an ML context that violates the memory usage policy enforced by Rust's type system. This leads to the question of how developers ought to reason about code in such a multi-language world where behavior inexpressible in one language is easily realized in another. This paper proposes the novel idea of linking types to address the problem of reasoning about single-language components in a multi-lingual setting. Specifically, linking types allow programmers to annotate where in a program they can link with components inexpressible in their unadulterated language. This enables developers to reason about (behavioral) equality using only their own language and the annotations, even though their code may be linked with code written in a language with more expressive power.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑