Types of DSLs

When designing a DSL, we have to decide between two types—external and internal.

An external DSL defines a new language. We have the flexibility to choose the syntax. We then parse the commands in our new language to take actions. When I started my first job, the company asked me to maintain a DSL that needed extensive use of lex and yacc. (I first thought they asked me to do it because I was good. I later understood they don’t ask new employees to do stuff because they’re good, but rather because no one else wants to do it!) The parsing was a lot of “fun.” We can use languages such as C++ and Java, and the support of extensive parsing capabilities and libraries, to do the heavy lifting for us. For example, we can use ANTLR to ...

Get Programming Groovy 2 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.