Selecting a good Template Engine is an important issue when dealing with code generation.
Since 1998 I’ve been testing almost lots of them and forming an opinion about it at the same time the technology evolved. Been at CG2009 and attending the session of Kathleen Dollard on Template Specialization brought to my mind all the times I wasn’t satisfied with my current template engine and changed to try for a new one.
Doing commercial code generators, I’ve been tested lost of techniques: direct string concatenation, XSLT, direct code generation (or what Kathleen calls brute force code gen), ASP, JSP based approaches, developing custom template engines (two of them), taking a look to Code Smith, T4 and others, using NVelocity and finally arriving till StringTemplate (for the moment).
This was my contribution for the Code Generation 2009 conference.
The central idea of my speech was devoted to achieve scalability in MDD tools & methods for industrial application of the MDD technology.
I was so glad to see that Markus Völter and Steven Kelly also just 30 minutes before my talk, were addressing the same key issues in their inspiring keynote: scalability, partitioning, modularization of DSL. This fact reinforce me in the idea that we are really growing as a community (CG) with common problems and aligned in the solutions improving the tools & techniques more and more every year.
Scaling MDD for production: enabling SoC at model time
There was also time for an small but complete live demo of a small tool socDriven running and demonstrating the concepts explained. The tool was implementing a compiler and merger for a small textual DSL. The DSL was parsed using the OSLO MGrammar to create the AST. A merged engine in a second phase glued the partial specifications producing as output:
- the same specs merged in a unique file,
- the same spec ready to be open with a graphical editor with DSL Tools,
- a full code generation solution on VS2008 containing:
- scripts for SQL Server
- a logic layers with POCOs & full NHibernate mappings
- a default CRUD service definition,
- a default Web Service definition,
- and a Windows Form UI ready to query and execute CRUD operations.
After the generation of the solution, it can be opened with VS, create the DB launching the scripts provided and pressing just F5 for building and running it all! == (a.k.a the utopia of 0 custom code) };-)
Please, feel free to add your comments!