By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,307 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,307 IT Pros & Developers. It's quick & easy.

Automated code generation

P: n/a
Yesterday there was an article on Slashdot:
http://books.slashdot.org/article.pl...id=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?
regards max M

Jul 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
In article <3f***********************@dread12.news.tele.dk> ,
Max M <ma**@mxm.dk> wrote:
Yesterday there was an article on Slashdot:
http://books.slashdot.org/article.pl...id=126&tid=156

It is about automatic code generation.

Jul 18 '05 #2

P: n/a

"Max M" <ma**@mxm.dk> wrote in message
news:3f***********************@dread12.news.tele.d k...
Yesterday there was an article on Slashdot:
http://books.slashdot.org/article.pl...id=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?
There are a few places where automated code generation makes sense,
but these are mostly trivial time savers. For example, the propery()
function
could be extended to automatically generate trivial getters, setters and
deleters, saving some coding and making things clearer in the majority
of cases.

John Roth

regards max M

Jul 18 '05 #3

P: n/a
Max M <ma**@mxm.dk> writes:
Yesterday there was an article on Slashdot:
http://books.slashdot.org/article.pl...id=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
Jul 18 '05 #4

P: n/a
Cameron Laird wrote:


Yes, it's largely useless in a language as dynamic as Python.

Isn't SWIG a code generator?
Al
Jul 18 '05 #5

P: n/a
In article <3F***************@easystreet.com>, <ac*****@easystreet.com> wrote:
Cameron Laird wrote:
>


Yes, it's largely useless in a language as dynamic as Python.

Isn't SWIG a code generator?
Al


I'm regarding SWIG as not about writing in Python; it's
about writing in a combination of Python and C (or C++,
or Fortran, or ...).
--

Cameron Laird <Ca*****@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://phaseit.net/claird/home.html
Jul 18 '05 #6

P: n/a
ac*****@easystreet.com wrote in message news:<3F***************@easystreet.com>...
Cameron Laird wrote:
Yes, it's largely useless in a language as dynamic as Python.


Isn't SWIG a code generator?


Most of what it generates is C++, Python is special in that there is
some optional wrapper code generated to use Python 2.2's features like
properties. No code, for example, is generated for Ruby (or Perl
AFAIK).

Eugene Pervago
Kahakai (Python scripted window manager) http://kahakai.sf.net/
Jul 18 '05 #7

P: n/a

My classes often have a __str__/__repr__ that generates a
bit of python code that when eval'd will reproduce (a clone of) the instance.

Simon.

On Fri, 05 Sep 2003 18:30:19 +0200, Max M wrote:

....
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?
regards max M


Jul 18 '05 #8

P: n/a
I write tools for testing embedded systems.
They parse the .h files and doc files to associate names with hex
values... This produces meg's of .py files which then support writing
tools and test scripts.

Everything from structure layout to:

EMERGENCY_STOP_CMD=0x1234567L
....
SOME_STRUCT=(["f1","f2","f3"],">fI10s")
....
ERROR_100="Somethig bad"
Does this qualify as code generation?

When the project wants to change something like how we "log".
Python is used to parse the entire source tree making changes.
Not Python code generation but it's more complicated than
search/replace. And could be applied to a Python code base as well

Is this code generation?

--Darrell
Max M wrote:
Yesterday there was an article on Slashdot:
http://books.slashdot.org/article.pl...id=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?
regards max M


Jul 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.