Re: The Challenge Of Metaprogramming

Yeah, macros are a little harder to write. But not much. A macro is just more Lisp code, so you already know the language of macros. And the output of your macro is also Lisp code, the code you want to see run. And you are already writing code to run at run time, so the only thing new is that you are writing code to write your code for you. And that is just a matter of figuring out the pattern in the boilerplate demanded by some API (including APIs you build yourself).

Yes, macros do more for the master than for the apprentice. If one does not notice the higher order pattern, one never conceives never mind can appreciate the opportunity to improve code. But any good tool benefits the expert more than the novice. I have seen structured programming, relational design, and OO design all misapplied by entusiasts.

No, macros do not make code harder to read. Why do you think we write them? We write macros to make code easier to read and write. That is why we are not dissuaded by the prospect of having to think a little more deeply.

And yes, easier also means shorter. A Macro hides repetitve syntax that obscures meaning, illuminating the semantics of an algorithm. Making code easier to read.

The analogy is that I am in a field of knee-deep mud trying to reach a goal a mile away. I look a hundred yards to my right and see a nice paved sidewalk leading right to the same goal. I'll have to climb a twenty-foot cliff I see between me and the path, but the cliff looks reasonable, I have climbed a lot, I actually like the challenge of climbing...

Look at it another way. You have a mixed bag of talent on a team anyway, some good, some great. The great ones are bored to tears churning out boilerplate. Lisp lets you reward better programmers with more challenging work, and lets you get more out of them, because their efforts will make the other folks insanely more productive (it's in the macro writer's job description). Shucks, you can even pay them more, enough to keep them because no one else can afford to pay them so much to churn out Java line noise.