Removing the boilerplate

Any DSL that we develop with Groovy is referred to as an embedded DSL. In other words, it uses language features from the host language in order to build a new mini dialect that achieves a particular goal. As programmers, we can appreciate the elegance of how a closure can define a mini dialect that is embedded within our code. We are used to all of the boilerplate that goes with using a Java library.

By boilerplate, we mean all of the setup code that is needed to establish the context in which our code is running. This could be connecting to a database, establishing a connection to a remote EJB object via a JNDI lookup, and so on. It also includes all of the other code, which is superfluous to the problem at hand but is ...

Get Groovy for Domain-specific Languages - Second Edition 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.