Tue Sep 1 18:31:07 CEST 2009

Dynamically Typed Metaprogramming

So.. Been thinking a lot about the static vs. dynamic typing for code
generators (staging) for a DSL.  I've isolated 2 regimes:

  1.  Fixed language semantics and implementation: code generators
      are small components that don't change.

  2.  Complex code generators, possibly evolving.

In case 1. the benefit of statically typed generators is not so great.
Once the generators work they will remain constant, so the added
benefits that types bring when modifying internal generator structure
doesn't pay off.  Abstract interpretation is probably enough to
perform checks at generator run time (DSL compile time), which is all
the DSL _user_ really needs.  In case 2. you probably want MetaOCaml
style typed staging.

I wonder what the compexity point is where typing starts to pay off.
One point I definitely see is complex DSP algorithms (i.e. video

Of course there is the constraint that metaprogramming needs to be
useful: you want to _lower_ the abstraction level of the
_implementation_ to get a clear view on resource usage, or dually you
want to _raise_ the abstraction level of the _specification_ starting
from a fixed platform (i.e. C / asm).