© Adam L. Davis 2019
Adam L. DavisLearning Groovy 3https://doi.org/10.1007/978-1-4842-5058-7_7

7. DSLs

Adam L. Davis1 
(1)
New York, NY, USA
 
Groovy has many features that make it great for writing DSLs (domain-specific languages):
  • Closures with delegates.

  • Parentheses and dots (.) are optional (command chains).

  • Ability to add methods to standard classes using Categories and Extension modules.

  • The ability to override many operators (plus, minus, etc.).

  • The methodMissing and propertyMissing methods.

Domain-specific languages can be useful for many purposes, such as allowing domain experts to read and write code or to clarify the meaning of business logic. They allow business experts to read or write code without having to be programming experts.

Closure with ...

Get Learning Groovy 3: Java-Based Dynamic Scripting 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.