Pattern 21Domain-Specific Language

Intent

To create a miniature programming language tailored to solve a specific problem

Overview

Domain-Specific Language is a very common pattern that has two broad classes: external DSL and internal DSL.

An external DSL is a full-blown programming language with its own syntax and compiler. It’s not intended for general use; rather, it solves some targeted problems. For instance, SQL is an instance of Domain-Specific Language targeted at data manipulation. ANTLR is another, targeted at creating parsers.

On the other hand, we’ve got internal DSLs, also known as embedded languages. These instances of the pattern piggyback on some general-purpose language and live within the constraints of the host language’s ...

Get Functional Programming Patterns in Scala and Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.