Workshop: unleashing the power of AST transformations
The Groovy language provides a wide scope of metaprogramming capabilities, making it a “very dynamic” language. One of those aspects, AST transformations, is about changing the internal representation of a program before it is actually executed. For example, using the @Log annotation, you can transparently add a logger field into a class. Using @ToString, you can have the compiler generate the toString method for you.
All those AST transformations are very powerful, but require a deeper knowledge of the compiler internals. In this workshop, we will introduce you from the beginning to AST transformations, describe the abstract syntax tree, setup a development environment and eventually, write some AST transformations so that you can contribute some in turn. The session will also show you some common traps, such as variable scoping, generics and compatibility with other AST transforms.
Slides and code:
Core Groovy committer
Cédric Champeau is a core Groovy committer. He joined SpringSource, a division of VMware, in order to help developing the language. Prior to that, he spent several years at Lingway, a software editor, where he used Groovy in multiple industrial contexts including DSLs for natural language processing, scripting or even workflows.
He his currently working on the implementation of static type checking and static compilation for Groovy 2.0.