Monday, January 5, 2009

A generated future

One of the things I like about Lisp is the fact that having a powerful macro capability in the language allows for concision in the code base that isn't available any other way. Unfortunately this leads to programmers minds exploding - powerful macros take time and patience to grok.

Near as I can tell, the other option for handling complexity also leads to programmer minds to explode. Instead of having an in language macro capability, I'm winding up generating code. The generated code, given it's weight in LoC has a similar mind bending capacity as Lisp macros, but the generated code is what is checked into revision control.

Is there a way out of this?

2 comments:

  1. I don't think so. Take c++ for example. There are several major ways for code shortcutting, and each of them have their own distinct strengths and weaknesses. Take templating vs Macro for example. Templating allows some pretty sofisticated things like template specialisation, or compile time type functionality checking, that are just impossible to achieve with macroing. On the other hand, there are things that macroing can achieve that you've got no hope of trying achieve with templating ie, code to string conversion and concatenation, inline without function infrastructure overhead, the list goes on. Same with generated code. I like what they've done with spirit, but, I think they're nuts to implement it in a template framework, when you can achieve so much more in a (DSL compiler?) code generator like antlr for example.

    Different tools for different jobs :)

    ReplyDelete
  2. I'm guessing by "compile time type functionality checking, that are just impossible to achieve with macroing" you are talking about c++ macros =)

    Lisp macros are a very different beast. But then, lisp doesn't usually have compile time type checking, so it's a bit moot. =)

    ReplyDelete