Metaprogramming Approaches compared
I was recently thinking about different approaches of meta programming. Specifically, I was comparing the approach taken by converge, and the one taken by Ruby. Of course, the primary difference is that Converge is compile-time, whereas Ruby is runtime meta programming. But there's another difference:
In
Converge,
the process works as follows: the parser reads your DSL-specific code into a parse tree based on a custom grammar. Then you as the meta programmer get a chance to process that parse tree - and what you'll typically do is to transform it into a regular converge AST. To make that simple, Converge provides macro facilities.
In
Ruby things work completely differently. You (mis)use all kinds of more or less obvious language features to somehow make your own DSL be valid Ruby code. As a consequence, the meta program often looks awkward, it is not easily understandable what happens. Also, you cannot use *any* syntax you want - because it has to be valid Ruby syntax.
I really think the approach taken by Converge is cleaner - since you have one clear transformation step, as opposed to using all kinds of eval, block and other trickery. It would be interesing to use it in a dynamic environment.
Any opinions?