There are two general ways to generate code: string templates and abstract syntax tree building. In Scala world we have a couple of options to build an abstract syntax tree. So, in this post I’m going to compare three different approaches: Generating code using string templates (Twirl). Generating code from an abstract syntax tree (treehugger). Building an abstract syntax tree and sending it direc