浅EDSL和面向对象编程:超越简单组合性
Shallow EDSLs and Object-Oriented Programming: Beyond Simple Compositionality
摘要:
嵌入式领域特定语言(Embedded Domain-Specific Languages,EDSL)是各种语言(包括Haskell和Scala)中常见且广泛使用的DSL方法。EDSL有两种主要的实现技术:浅嵌入和深嵌入。询问:浅嵌入非常简单,但在过去,它们因在模块化和重用方面非常有限而受到批评。特别是,经常有人认为在浅嵌入中支持多个DSL解释是困难的。方法:本文认为,浅层EDSL和面向对象编程(OOP)是密切相关的。Gibbons和Wu已经讨论了浅EDSL和过程抽象之间的关系,而Cook讨论了过程抽象和OOP之间的联系。本文中我们通过过程抽象将浅层EDSL直接连接到OOP来实现过渡步骤。关于这种关系的知识使我们能够改进EDSL的实现技术。知识:本文认为,共同的OOP机制(包括继承,子类型,类型细化)增加了模块化和重用的浅EDSL相比,经典的过程抽象,使一个简单的方法来表达多个,可能依赖,解释。基础:我们通过使用Gibbons和Wu的例子来进行论证,其中Haskell使用过程抽象来建模一个简单的浅EDSL。我们在Scala中重新编码EDSL,并使用改进的OO启发的Haskell编码。我们进一步说明了我们的方法与案例研究重构深外部SQL查询处理器,使其更加模块化,浅,嵌入式。重要性:这项工作之所以重要,有两个原因。首先,从知识的角度来看,这项工作建立了浅嵌入和面向对象程序设计之间的联系,使人们能够更好地理解这两个概念。其次,这项工作说明了编程技术,可用于提高浅EDSL的模块化和重用。
英文摘要:
Context: Embedded Domain-Specific Languages (EDSLs) are a common and widely used approach to DSLs in various languages, including Haskell and Scala. There are two main implementation techniques for EDSLs: shallow embeddings and deep embeddings. Inquiry: Shallow embeddings are quite simple, but they have been criticized in the past for being quite limited in terms of modularity and reuse. In particular, it is often argued that supporting multiple DSL interpretations in shallow embeddings is difficult. Approach: This paper argues that shallow EDSLs and Object-Oriented Programming (OOP) are closely related. Gibbons and Wu already discussed the relationship between shallow EDSLs and procedural abstraction, while Cook discussed the connection between procedural abstraction and OOP. We make the transitive step in this paper by connecting shallow EDSLs directly to OOP via procedural abstraction. The knowledge about this relationship enables us to improve on implementation techniques for EDSLs. Knowledge: This paper argues that common OOP mechanisms (including inheritance, subtyping, and type-refinement) increase the modularity and reuse of shallow EDSLs when compared to classical procedural abstraction by enabling a simple way to express multiple, possibly dependent, interpretations. Grounding: We make our arguments by using Gibbons and Wu's examples, where procedural abstraction is used in Haskell to model a simple shallow EDSL. We recode that EDSL in Scala and with an improved OO-inspired Haskell encoding. We further illustrate our approach with a case study on refactoring a deep external SQL query processor to make it more modular, shallow, and embedded. Importance: This work is important for two reasons. Firstly, from an intellectual point of view, this work establishes the connection between shallow embeddings and OOP, which enables a better understanding of both concepts. Secondly, this work illustrates programming techniques that can be used to improve the modularity and reuse of shallow EDSLs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。