* Andrew Strader <astrader at ecnext.com> [2006/07/10 09:20]: > Dynamic code generation with templates is intriguing, but beware of > it drifting toward static code generation. [-- snip --] > Static code generation an instance of false laziness. You must learn > the abstractions relevant to your favorite programming paradigm.
I'm not sure I agree with this. There are probably more examples of static code-generation that are not evil than those that are, actually. Things like generating HTML or XML (via ttree, for example) are good examples. Generating executable code from UML models is another good example[0]. I've used TT to "statically" write PHP, SQL[1], PDFs, Postscript[2], HTML[3], and images[4]. There's nothing wrong with static code generation, if done correctly. > Almost every mainstream programming language follows is > object-oriented to some degree, so you can define a base class for > the most general solution. This is probably beside the point, as code generation and object-oriented programming don't always solve the same problems. As long as you don't lose track of what you're generating and what you aren't, it's entirely possible to generate your code. (darren) [0]: http://sqlfairy.cvs.sourceforge.net/sqlfairy/sqlfairy/lib/SQL/Translator/Producer/DiaUml.pm?view=log [1]: http://sqlfairy.sf.net/ [2]: http://www.template-toolkit.org/docs/leon/Library/PostScript.html [3]: http://www.template-toolkit.org/docs/leon/Library/HTML.html [4]: http://www.template-toolkit.org/docs/leon/Modules/Template/Plugin/GD/Image.html -- I'd rather have my own game show than enough votes to become president.
pgphscF3vHIl0.pgp
Description: PGP signature
