Joist uses two types of code generation:
joist.domain’s code generation is well suited to build-time code generation because it:
joist.web’s code generation is well suited to design-time code generation because it:
Joist avoids runtime code generation because it:
Both joist.domain and joist.web (via bindgen) use joist.util’s sourcegen.
sourcegen provides an abstraction layer of GClass, GMethod, and GField objects for generating source code into an object tree instead of a raw template, mostly ignoring tedious issues like class-level formatting, organizing imports, etc.
sourcegen also allows decomposition of the generation logic, as a GClass can be passed to different modules for each to decorate, instead of all the logic for a class being commingled in a single template.
joist.domain generates meta-data that drives the joist.domain ORM implementation at runtime, so it avoids generating low-level persistence code.
This avoids complexities like directly generating SQL strings, but still provides a type-safe meta-data basis for the rest of the application and joist.domain implementation to leverage.