Is code generation a sign that you are missing a layer of abstraction?
This doesn’t feel like a new thought, so I may have read it somewhere, or possibly even blogged it.
It seems to me that code generation is most often seen in statically typed languages such as java, and even then could conceivably be alternatively implemented with an additional layer of abstraction that expressed the intent of the generated code at a higher level.