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 ...

Get Get Programming with JavaScript Next 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.