Re:Writing code that writes code – Hack Codegen
by jeanetienne on Thursday August 20, 2015 @07:44PM
(#10095252)
Am I the only one to be bothered by the fact that both examples of codegen/generated code shows that you have to write more codegen to generate less actual code?
In the first example there more than twice the amount of code written in the codegen than in the generated code...
I know they are simple example but still, if I have to write more code for all the simple getters/setters, it defeats the purpose of the codegen which is to "reduce boilerplate".
Am I missing something?
[ Parent
| on HN ]
Re:Writing code that writes code – Hack Codegen
by zeroonetwothree on Thursday August 20, 2015 @09:37PM
(#10095533)
Each codegen is run multiple times. Imagine you want to generate 100 similar classes with similar code except for a small difference.
Re:Writing code that writes code – Hack Codegen
by epaga on Friday August 21, 2015 @02:41AM
(#10096246)
But that would be a code smell akin to copy-pasting code wouldn't it?
I'm having trouble seeing any real-world scenarios for this kind of codegen but since it seems to be in wide use at Facebook, I must just be missing something...