I would often prefer to have this kind of code generation to magic reflection or dynamism at runtime, especially if runtime magicks come with a performance cost. For example in JavaScript you can intercept any method call or object access at runtime using Proxy, or in Ruby using method_missing, but it such code is often hard to maintain and understand.
If you statically generate a bunch of methods from a schema, it’s very easy to just read the output source, and the JIT is much happier with the code.
If you statically generate a bunch of methods from a schema, it’s very easy to just read the output source, and the JIT is much happier with the code.