Shallow EDSLs and Object-Oriented Programming: Beyond Simple Compositionality

02/01/2019
by   Weixin Zhang, et al.
0

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.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
03/27/2018

Live Multi-language Development and Runtime Environments

Context: Software development tools should work and behave consistently ...
research
02/01/2019

Separating Use and Reuse to Improve Both

Context: Trait composition has inspired new research in the area of code...
research
05/22/2021

Choosing is Losing: How to combine the benefits of shallow and deep embeddings through reflection

Dependently-typed host languages empower users to verify a wide range of...
research
10/01/2019

Mμl: The Power of Dynamic Multi-Methods

Multi-methods are a straightforward extension of traditional (single) dy...
research
11/26/2019

GOOL: A Generic Object-Oriented Language (extended version)

We present GOOL, a Generic Object-Oriented Language. It demonstrates tha...
research
12/09/2022

A Model Driven Approach on Object Oriented PLC Programming for Manufacturing Systems with regard to Usability

This paper presents the modular automation for reuse in manufacturing sy...
research
11/09/2022

An Empirical Study on Clustering Pretrained Embeddings: Is Deep Strictly Better?

Recent research in clustering face embeddings has found that unsupervise...

Please sign up or login with your details

Forgot password? Click here to reset