Compositional embeddings of domain-specific languages

1Citations
Citations of this article
7Readers
Mendeley users who have this article in their library.

Abstract

A common approach to defining domain-specific languages (DSLs) is via a direct embedding into a host language. There are several well-known techniques to do such embeddings, including shallow and deep embeddings. However, such embeddings come with various trade-offs in existing programming languages. Owing to such trade-offs, many embedded DSLs end up using a mix of approaches in practice, requiring a substantial amount of code, as well as some advanced coding techniques. In this paper, we show that the recently proposed Compositional Programming paradigm and the CP language provide improved support for embedded DSLs. In CP we obtain a new form of embedding, which we call a compositional embedding, that has most of the advantages of both shallow and deep embeddings. On the one hand, compositional embeddings enable various forms of linguistic reuse that are characteristic of shallow embeddings, including the ability to reuse host-language optimizations in the DSL and add new DSL constructs easily. On the other hand, similarly to deep embeddings, compositional embeddings support definitions by pattern matching or dynamic dispatching (including dependent interpretations, transformations, and optimizations) over the abstract syntax of the DSL and have the ability to add new interpretations. We illustrate an instance of compositional embeddings with a DSL for document authoring called ExT. The DSL is highly flexible and extensible, allowing users to create various non-trivial extensions easily. For instance, ExT supports various extensions that enable the production of wiki-like documents, LaTeX documents, vector graphics or charts. The viability of compositional embeddings for ExT is evaluated with three applications.

References Powered by Scopus

Template meta-programming for Haskell

406Citations
N/AReaders
Get full text

The spoofax language workbench: Rules for declarative specification of languages and IDEs

240Citations
N/AReaders
Get full text

Data types à la carte

214Citations
N/AReaders
Get full text

Cited by Powered by Scopus

super-Charging Object-Oriented Programming Through Precise Typing of Open Recursion

1Citations
N/AReaders
Get full text

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Cite

CITATION STYLE

APA

Sun, Y., Dhandhania, U., & Oliveira, B. C. d. S. (2022). Compositional embeddings of domain-specific languages. Proceedings of the ACM on Programming Languages, 6(OOPSLA2). https://doi.org/10.1145/3563294

Readers' Seniority

Tooltip

Professor / Associate Prof. 2

67%

Lecturer / Post doc 1

33%

Readers' Discipline

Tooltip

Computer Science 2

67%

Design 1

33%

Save time finding and organizing research with Mendeley

Sign up for free