When code generation arises as a routine technique, it means your language lacks sufficient power of expression for coping with your problem domain.

Corollary: Code generation should (almost) never be necessary in any sufficiently advanced programming environment.