Automated code generation

Eddie Corns eddie at holyrood.ed.ac.uk
Fri Sep 5 20:33:51 CEST 2003


Max M <maxm at mxm.dk> writes:

>Yesterday there was an article on Slashdot:
>http://books.slashdot.org/article.pl?sid=03/09/04/1415210&mode=flat&tid=108&tid=126&tid=156

>It is about automatic code generation.

>I got interrested in the subject, did a web search, and it seems kind of 
>powerfull.

>My main interrest is web development in Zope/CMF/Plone, where there is a 
>lot of repeated code in the products. So automated code generation seems 
>like a natural fit.

>But every time I think of a use case, I immediately think of a way to do 
>it with encapsulation instead.

>Does anybody have any experience using Python and automated code 
>generation where it actually make sense?

>Or os it useless in a language as dynamic as Python?

The target language doesn't have to be the same as the implementation
language.  A short while ago I created a small code generation program that
created snippets of C code which were woven into a hand optimised C program.
The result was an extremely fast program (which it needed to be) which still
seemed to have some capabilities of the HLL I used to create it (Scheme in
this case).  I wouldn't even have attempted doing the analysis of the user
input in C but it was so trivial in Scheme I was able to add lots of extras.
It would have been a reasonable project in Python too.  I did in fact use
Python as a front end to hide what was happening.

However I would suspect there would be a lot less scope for generating Python
code.  Its dynamic and reflexive nature make it unnecessary.

Eddie




More information about the Python-list mailing list