Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Code Generation with Perl?

by perrin (Chancellor)
on Oct 03, 2003 at 23:48 UTC ( #296434=note: print w/ replies, xml ) Need Help??


in reply to Code Generation with Perl?

The book Advanced Perl Programming has a whole chapter on this, and there is also this article on perl.com. However, code generation (at least when it involves actual files, as opposed to just AUTOLOAD and eval magic) often indicates that you're doing something wrong. This has been widely discussed under the term "code smell." The gist of it is that your language should be able to factor out repetitive tasks without needing to actually generate code to do it. Also, code generation systems often lead to bad situations where people edit the generated code by hand and then can't generate it again without losing that work. So, use with caution.


Comment on Re: Code Generation with Perl?
I couldn't agree more
by cbraga (Pilgrim) on Oct 04, 2003 at 00:13 UTC
    My take is that code generation is a necessity when you need to express concepts difficult for a language. Case in point, compilers generated in C with yacc/bison. While we certainly could write those by hand in C, generating code is much more productive because we can work in a level of abstraction impossible in the target language without sacrificing C's efficiency.

    Not the case with Perl, though. Perl is at a much higher level than C and I've yet to see a case where we actually need to generate Perl code due to the difficulty of writing it directly in the first place. The cases I've seen do it for performance. Even Autoload, while convenient, could be done away with without losing much, I think.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://296434]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2014-07-10 17:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (214 votes), past polls