Lisp blazed the trail, (code generation and dynamic languages)
Three posts in today's RSS feeds mentioned code generation. My first exposure to code generation was in contributions to Torque (which also made me a Turbine committer).
While talking about Spring, Chris mentioned a new code generation system he's written.
Simon prefers data driven programming to code generation.
We considered using code generators for our current major project at work, and picked up Jack Herrington's book on the subject. Reading through it, it became clear that many of the problems that code generators solve can be tackled instead using data driven programming techniques made possible by dynamic languages. Since we had already settled on Python as our implementation language the need for code generation became far less apparent, and we ended up avoiding it entirely with the exception of a command line tool for passvely generating basic templates for our admin interface.
Jon endorses dynamic languages while discussing Programs That Write Programs.
We've always known that dynamic languages are a great way to create "little languages" for specific tasks. But we don't yet fully appreciate that all programming is a continuous process of language invention. And we don't (yet) evaluate programming-language productivity on those terms. .... We are linguistic animals endowed with a protean ability to generate language. Naturally we'll want that same generative power in our programming languages.
Jon has written a perfect description of lisp. Guy Steele shared this wisdom in his inspired presentation at OOPSLA 1998 Growing a Language. (140K PostScript) Paul Graham calls it bottom-up programming. I'm still slowly working my way through On Lisp. Lisp macros are code generators -- programs that write programs. Code generation is baked into the language. Although, Paul says macros make lisp more powerful than other languages, he also observes "macros are harder to write than ordinary Lisp functions, and it's considered to be bad style to use them when they're not necessary."
Lisp is the mother of dynamic languages. Its secret power is in the ease with which it can be extended into custom "little languages" which match the domain of the program under development. But code generation is only a part of that power. Functions and lexical closures are also quite powerful.
I've been programming in perl since I joined as an apprentice to bivio Software Artisans. In 1999 perl [was chosen] for [its] Lispishness, ubiquity and reliability. Though python and ruby are more fashionable, perl is still quite capable and lispish. It's fun applying lessons from On Lisp to my daily perl hacking. It's also fun learning to grow a language.
The future is here, just not evenly distributed. Lisp programmers understand about the process of continuous language invention. It's the rest of us who have yet to fully embrace that wisdom. The bad news is that it's hard work expanding your programming mind set, judging by the time it's taking me to digest On Lisp. The good news is the lisp hackers have been blazing this trail for over 40 years and there are good travel guides if you ever decide to set out in that direction.