Writing code that writes code has proven to be valuable for keeping software scalable and maintainable. Moreover, code generation techniques significantly increase the profitability of software in many areas. Template engines have been available for decades for classical programming languages as well as web-based environments. DSL development tools like Eclipse Xtext do a great job on assisting us in developing solutions on the Java platform, for example.
In this talk I will showcase the development of a code generator in TypeScript being executed on Node.js. My presentation includes solutions for:
- the whitespace problem
- unfolding definitions into different generated artifacts
- mastering complexity by introducing intermediate representations
- testing the generator