When Bjarne Stroustrup first implemented C++Code generation is an anti-pattern when it was called "C With Classes". The implementation worked by generating C source code; that became known as CFrontcosts more than it accomplishes.
It should be obvious that you don't get the equivalent of This situation occurs when generation takes place from A to B where A is almost the C++same language simplyas B, but with some minor extensions that could be done just by writing codecoding in C, ratherA with less effort than writing C++all the custom tooling and having that translatedbuild staging for A to CB.
Generating sourceThe trade off is more prohibitive against code lets us have a different language which expresses solutionsgeneration in different styles. Also, it lets us have higher level languages insteadthat don't have meta-programming facilities (structural macros) because of writing in assembly language. Though some compilers generate machine code directly, the generationcomplications and inadequacies of assembly language is also an approach which is used, with equivalent results. That is also "source code generation"achieving metaprogramming through the staging of external text processing.
InsteadThe poor trade off could also have to do with the quantity of generating assembly languageuse. Language A could be substantially different from a higher level languageB, we could write proceduresbut the whole project with its custom code generator only uses A in assembly language. That would be timeone or two small places, so that the total amount of complexity (small bits of A, plus the A -consuming to develop and debug> B code generator, and also have to be rewritten when ported to another processorplus the surrounding build staging) exceeds the complexity of a solution just done in B.
The nice thing aboutBasically, if we commit to code generation is that, we can adjust some parameters in it and runshould probably "go big or go home": make it again. If a human coder makes the same mistake repeatedlyhave substantial semantics, it has to be individually hunted down and fixed. If a code generator makesuse it a systematic mistakelot, we fix that in the code generator and then just run it again on the code baseor don't bother.