Re: A "killer" macro
- From: sharpquote@xxxxxxx
- Date: Mon, 17 Sep 2007 02:21:42 -0000
On Sep 12, 2:59 am, Eli Bendersky <eli...@xxxxxxxxx> wrote:
Hello all,
In short: I'm looking for a "killer" macro - a macro (or a couple of
related ones) that show what Lisp can do and other languages (those
without uniform syntax) can not.
I don't think such a thing exists, in the context (evangelism) that
you want it. There are plenty of killers out there, but any of them
could be included as a feature in another language, or simulated
(probably clumsily) in almost any language. The "killer" macro, in CL
is that you can write your own macros, not any particular macro. If
you are really interested in evangelism (I'm not, except to the
already receptive), that is the point about macros that must be driven
home, and even simple macros can serve that purpose- they might even
be better for that purpose than more complex macros, as your audience
is more likely to understand the mechanism, instead of pointing out
equivalent feature X in their pet language, or getting bogged down in
the swamp of Turing equivalence.
A longer version: Many contemporary languages boast their sharing most
of the functional features of Lisp. Perl, Ruby, Javascript - all have
convenient lists (or arrays), functions as first class objects,
garbage collection, dynamic typing, lexical closures. However, one
thing they lack is uniform syntax, and hence the service of a powerful
built-in macro system such as Common Lisp's "defmacro".
When confronted by fellow programmers with the question "so why is
Lisp so special",
The answer to that is not, IMHO, one killer macro, nor is it CL's
macro facility, in isolation. If you push a "killer" macro as CL's
strong point you just invite people to show that that macro can be
mimicked in some other language. In the worst case their pet language
was explicitly designed to do what your "killer" macro does, and does
that one thing more elegantly... that is called "having been
'Harroped'". Anyone can be Harroped, so be careful out there. It's
embarrassing _and_ unsightly- and there is evidence that it is
contagious[1].
I'm looking for that short - not too hard to
understand - snippet of code that will show them *why*. I'm convinced
that such a snippet must involve macros. But all the examples I ran
into so far have been either too simple - and could be easily
implemented another way (for example with Ruby's blocks), or too
complicated.
Anything really simple in CL will have a reasonably simple expression
in some other language. For that matter, anything that is truly simple
in CL is likely not impossibly difficult in some macro-equipped
assembler. What gets missed here is that developing it will be, at
least for me, much more pleasant in CL. I think that is the point to
hammer home, if you are interested in CL evangelism. Real programming,
like anything else worth doing (leaving aside things like sex, skiing,
and eating ice cream), is at times very painful- painful enough to
leave you wondering if you should have been a sex instructor, or
pimped some skiers to the highest bidder... anything that makes it
less painful will be welcomed, if the reduction in pain can be shown
to be greater than the pain of adjusting to a new environment added to
the pain of giving up preconceptions.
The problem is that it is not one feature of Lisp that makes Lisp more
pleasant to me. It is the interaction of many of CL's features that
makes it attractive. Actually, it is the way that I develop in CL that
I value- I only value CL's features because they make that development
style possible. This is where you go wrong, I think- you are trying
to sell features, in the abstract, instead of selling value. You are
also selling steak instead of sizzle, but that is, while related, not
quite the same thing.
Any suggestions for such an example ?
I'm not that interested in Lisp evangelism in the large, but I've done
a lot of it in the small, and I think that that may be of more value,
in the end, than public bickering over whether Python or Ruby (or even
Scheme) is an "acceptable Lisp". The only way I can show someone why
I like CL (and, by extension, why they should) is to sit down with
them and write a simple, but interesting program. I don't usually
define macros when I do this, as I'm often sitting down with
programmers who need to be coached into recursing on cdrs, and have
never even seen a real tree, let alone figured out how to traverse it.
I just try to show them how some subset of features interacts to make
a pleasant development experience, preferably with a problem they
would find difficult to solve in their normal environment. I have this
down to "patter" at this point, but that patter is derived from real
problems I have had to solve
I don't think you can show why it is nicer to develop in CL than in X
environment by displaying a macro. I also think it is hard to pry
people away from their favorite language, if it is any good at all-
the harder you try, the harder it becomes. I'd rather concentrate on
the VB programmers I know than on the Python programmers I don't- and
I do that for their sake, not Lisp's.
If you really want to evangelize CL, in the large, I see three ways to
do it, in order of preference:
1) start a business that requires and allows you to hire CL
programmers (i.e. money, mouth)
2) personally teach people who really need help- the above VB
programmers, who will be receptive to anything that makes the pain go
away for a minute
3) libraries
*** length comparison with good [insert language here] programmers
via "killer" macros ranks 4th, rather than 101st, only because I do
not enumerate 4-100. The only thing you will get out of that is an
explanation of how to do what your killer macro does in language X-
that might be educational, but it's unlikely to serve your purpose.
.
- Follow-Ups:
- Re: A "killer" macro
- From: Leandro Rios
- Re: A "killer" macro
- References:
- A "killer" macro
- From: Eli Bendersky
- A "killer" macro
- Prev by Date: Re: saving values for reloading and macro de-uglification
- Next by Date: Learning LISP from scratch
- Previous by thread: Re: Boost::ScopeExit [Re: A "killer" macro]
- Next by thread: Re: A "killer" macro
- Index(es):