Joist’s code generation is well suited to build-time code generation because it:
Joist avoids runtime code generation because it:
Joist uses sourcegen, a Java code generation DSL.
sourcegen provides an abstraction layer of
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 generates meta-data that drives the 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 implementation to leverage.