Chapter 9. Compile-time metaprogramming and AST transformations

This chapter covers

  • Removing redundancy and verbosity with Groovy’s metaprogramming annotations
  • Writing your own compiler extensions using the AST transformations feature
  • Compile-time metaprogramming testing, tools, and pitfalls

It is my firm belief that all successful languages are grown and not merely designed from first principles.

Bjarne Stroustrup, The Design and Evolution of C++

The previous chapter covered dynamic programming with Groovy, where the behavior of a type or even an individual object can change while the program is executing. You don’t always need the behavior to vary that dynamically though—sometimes you want only to be able to apply common patterns in an ...

Get Groovy in Action, 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.