Semantics-Driven DSL Design

Semantics-Driven DSL Design

Martin Erwig (Oregon State University, USA) and Eric Walkingshaw (Oregon State University, USA)
DOI: 10.4018/978-1-4666-2092-6.ch003
OnDemand PDF Download:
$30.00
List Price: $37.50

Abstract

Convention dictates that the design of a language begins with its syntax. The authors of this chapter argue that early emphasis should be placed instead on the identification of general, compositional semantic domains, and that grounding the design process in semantics leads to languages with more consistent and more extensible syntax. They demonstrate this semantics-driven design process through the design and implementation of a DSL for defining and manipulating calendars, using Haskell as a metalanguage to support this discussion. The authors emphasize the importance of compositionality in semantics-driven language design, and describe a set of language operators that support an incremental and modular design process.
Chapter Preview
Top

Introduction

Despite the lengthy history and recent popularity of domain-specific languages, the task of actually designing DSLs remains a difficult and under-explored problem. This is evidenced by the admission of DSL guru Martin Fowler, in his recent book on DSLs, that he has no clear idea of how to design a good language (2010, p. 45). Instead, recent work has focused mainly on the implementation of DSLs and supporting tools, for example, through language workbenches (Pfeiffer & Pichler, 2008). This focus is understandable—implementing a language is a structured and well-defined problem with clear quality criteria, while language design is considered more of an art than an engineering task. Furthermore, since DSLs have limited scope and are often targeted at domain experts rather than professional programmers, general-purpose language design criteria may not always be applicable to the design of DSLs, complicating the task even further (Mernik et al., 2005).

Traditionally, the definition of a language proceeds from syntax to semantics. That is, first a syntax is defined, then a semantic model is decided upon, and finally the syntax is related to the semantic model. This widespread view is reflected in the rather categorical statement by Felleisen et al. that the specification of a programming language starts with its syntax (2009, p. 1). This view has been similarly echoed by Fowler, who lists defining the abstract syntax as the first step of developing a language (2005) (although he puts more emphasis on the role of a “semantic model” in his recent book (2010)).

In this chapter we argue for an inversion of this process for denotationally defined DSLs, where the semantic domain of the language is identified first, then syntax is added incrementally and mapped onto this domain. We argue that this semantics-driven approach to DSL design leads to more principled, consistent, and extensible languages. Initial ideas for semantics-driven DSL design were developed in our previous work (2011). This chapter expands these ideas and explains the process and the individual steps in detail.

Complete Chapter List

Search this Book:
Reset