Macros Considered Harmful (International Lisp Conference, 2009)
March 25, 2009
The grandious title of the debate that was to happen at the International
Lisp Conference (50 years!) at MIT that night.
I had skipped work and paid my own way in. ($250 for four days?! Deal!!!!)
Bunch of friends. Some people I idolize. Lots of eager youngesters
with their ideas, hopes, and dreams. This was cool. RMS* even showed up
for a brief stint.
I wasn't planning on signing on for a "Lightning Talk," but Henry
Lieberman talked me into it. I like talking, but at the same time....
Wow. I have five minutes to say something coherent about debugging
while running a demo. And they cut you off in mid-word if you go
over. That adds a bit of adrenline into the system.
I had all night to prepare, after all.
The debate...
It was RPG*, Dan Wienweb, JonL*, and oh, what's his name!
The great QUUX* moderated.
What's his name proposed the above slogan. He made a series of
intelligent and very serious arguments for why macros cause more
problems than they solve. The opposition pretty much said "Freedom!
Power! Personal Responsibility!"
This is a Lisp crowd, so it got a little roudy. Lispers *love* their
macros!
And yet, the arguments were cogent. Especially in Lisp, where macros
can have side-effects that change how later files will be compiled.
Arguments against:
"We have experienced so many problems with side-effects in macros that
we in the Lisp world cannot do a reliable incremental build." No one
really disagreed.
"Macros obscure the code. They're easy to write, but hard to
read. Your code will be more understandable in six months if you don't
use macros." This point evoked debate. "Macros allow me to say more
clearly what I intend."--"That's fine for you now, but it will become
black magic to anyone else reading your code."
"Macros are really hard to write correctly. And you probably won't be
the one to use them in a corner case where they fail." The reply was
largely "You can write bad code without macros. It's the programmer's
responsibility."
Arguments for:
"Macros allow me to say more clearly what I intend."
"Macros allow me to create a new language inside of Lisp. This is *so*
useful for writing "Domain Specific Languages." The reply here was to
go the whole way and write a compiler for the new language.
Then people starting throwing symbolic tomatoes and it got silly. At
one point, somebody said something in the debate about MIT using
Python instead of Scheme. It ended up with Gerry Sussman coming down
onto the floor and spending 5 minutes explaining how the nature of the
students and the general environment had so radically changed from the
Heyday of 6.001, that he let others deterime how intro would be taught.
But back to the debate! (er... riot?)
My contribution was the observation that as a Lisper, I had happily
written many a macro. But as a Java dude, I don't write them (uh, Java
doesn't *do* macros.) And I don't want them either! I do not see
anywhere in my code that I would use a macro. I'd rather type an extra
line than depend on an unknown transformation.
And I feel my code is far better now than it was then.
I got... uh... shouted down. The crowd was turning ugly.
10pm came, went, then "OMG! We have to be out of here 10 minutes ago!
RUN!!!!"
There was no real conclusion. But it was good to talk about it.
[Next: Lightning Strikes!]
*Richard M Stallman
*Richard P Gaberial
*Guy L Steele
*Jon L White
(I know their logins names from 1980! This is sad... :-)