Posted on 02 October, 2011 (10 years ago)
Modified on 04 October, 2011 (10 years ago)
is a powerful language that gives the opportunity to its users to plugin into the compilation process to create what we call AST transformations
, ie. the ability to customize the Abstract Syntax Tree representing your programs before the compiler walks this tree to generate Java bytecode.
Since Groovy 1.6, many useful such transformations have been added to Groovy, like @Delegate
to implement delegation, @Immutable
to make your types immutable, or @Grab
to add dependencies to your scripts, and many more. However, mastering the Groovy AST and compiler APIs is not such a simple task, and requires some advanced knowledge of the inner workings of Groovy.
If you're interested in writing your own transformations, those very well written articles are really a great start that should get you up to speed very rapidly.