Essay 49 | Generating Code at Its Core |
Taking the leap into code generation is an important pilgrimage every developer ought to take. It frees us to think about code as a powerful tool to transform how we work, not just as merely the material we use to write programs.
So, how do we actually write a generator? For a truly in-depth source, I highly recommend Jack Herrington’s outstanding book, Code Generation in Action [Her03]. It covers detailed techniques and high-level patterns for generating code of all kinds. But we don’t need that level of detail to get started. Here are the essentials.
Define Your Input Source
First, create an input source. It’s the place that houses all the parameters our code generator needs to do its work. The input ...
Get The Developer's Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.