[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: In search of cool Scheme

From: Alex Shinn
Subject: Re: In search of cool Scheme
Date: 22 May 2001 12:00:59 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.100

>>>>> "Sam" == Sam Tregar <address@hidden> writes:

    Sam> Hello all.  I need some cool Scheme.  I'd like to find a
    Sam> small Scheme function or two that non-Scheme people might be
    Sam> easily impressed by.  Something to answer the question "Why
    Sam> Scheme?".  The non-Schemers I'm targetting are Perl users, so
    Sam> no pattern-matching or text-munging is allowed.  Perhaps
    Sam> someone has something that would be quite hard in Perl but is
    Sam> easy in Scheme?  Maybe some complex tree manuevers or
    Sam> self-modifying AI code?

Perl is sort of a poor man's Lisp with lots of syntax and context
sensitivity.  As such, there's not much you can do in Scheme that you
can't in Perl (e.g. Perl can do the Y-combinator and there's a Perl
module for Currying).

One of the big arguments against Perl is specifically the quick and
easy syntax and context sensitivity - it makes Perl code that much
harder to understand and maintain.  So if you've a large application,
a cleaner language like Scheme would be more appealing.

Likewise, the one "feature" of Scheme which is hard to reproduce in
Perl is the minimal syntax.  This makes it easy to parse and build
dynamic Scheme.  For example, the structure of Scheme is very similar
to XML, and there's an XML parser at

which also has modules for translating the XML into Scheme.  This is
just waiting to be turned into a truly powerful but fast application
server to put Zope to shame (to say nothing of the attempts at Perl
application servers).

Another big win from the simple syntax is the ability to define
macros.  Thus it's a simple matter to define, say, an object system in
Scheme.  In Perl, the OO system is a strange hack which had to be
built into the language core and requires people to learn new syntax.
Most Scheme OO systems are portable, written in Scheme itself and
using standard Scheme syntax.  This is because you can create

  (define-class foo (parents))

as a macro which will do all the work of creating the foo class with
parent classes (parents), without evaluating foo or parents.  It would
be impossible to create a Perl defclass function to handle

defclass foo (parents) { ... }

If you search on /. for recent articles about Yahoo and/or Lisp, there
was one recently where the creator of Yahoo Store explains he was so
successful because he chose Lisp as a language, and cited macros as
the single most important feature.  Scheme provides two types of
macros, one like Lisp and a cleaner version (syntax rules).

So I guess the advantages are more subtle, and thus it's hard to come
up with cute little code snippets of things that are hard in Perl.
Maybe something using force/delay or string-port handling?  You can do
interesting things with continuations, but that might just scare
people away :-)

Alex Shinn <address@hidden>
Lisper, Smalltalker, and all around poor speaker

reply via email to

[Prev in Thread] Current Thread [Next in Thread]