O'Reilly logo

Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond by JD Isaacks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lesson 8. Capstone: Building a domain-specific language

In this project, you will

  • Learn what a domain-specific language (DSL) is
  • Create a simple DSL for handling user input from an HTML formatter
  • Create a simple DSL for repeating or looping templates around an array

Before you build a DSL, let’s first define what one is. A domain-specific language uses a programming language’s features and syntax in a clever way to make solving a particular task appear as if it has first-class support by the programming language itself. For example, a common type of DSL seen in JavaScript is used by unit test libraries:

describe('push', function() {
  it('should add new values to the end of an array', function() {
    // perform test
  });
});

This is a DSL because ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required