merits of Lisp vs Python

Bill Atkins not-a-real-email-address at not-a-real-domain.com
Mon Dec 18 03:29:52 EST 2006


This is not a response to any particular post, but rather to the
general argument that macros are not as useful as we Lispers claim.

Here is a fairly complete GUI RSS reader in 90 lines of Lisp (the GUI
code itself is 90 lines, but it makes use of some RSS reading/writing
code I had laying around and two public CL libraries: s-xml and
trivial-http).  The code employs a handy macro called DEFINE-INTERFACE
that LispWorks provides with their CAPI toolkit.  I hope this will be
useful as an illustration of what macros (and Lisp in general) can do,
and as an example of what a moderately practical CL application looks
like.

The application presents a list of feeds and allows the user to add
new feeds or to delete existing feeds.  The feeds are presented as a
tree, with each channel acting as a parent to several items.  The user
can refresh all of the feeds with the "Refresh All" button.
Double-clicking on any item will display its description field (as in
the screenshot).  Each channel shows the number of unread articles and
the articles are arranged so that the unseen articles appear before
the articles that have already been read.

Important things to note:

 1) the DEFINE-INTERFACE syntax closely resembles the syntax of the
    standard DEFCLASS macro, so newcomers have a basic idea of what
    DEFINE-INTERFACE is going to do

 2) the expansion ( http://galoot.org/~bill/code/rss-reader/expanded.lisp )
    of just the DEFINE-INTERFACE is quite involved, a testament to
    the amount of work the macro saves

 3) much of the GUI can be specified declaratively because of the
    DEFINE-INTERFACE syntactic abstraction, and this declarativeness
    makes it very easy for maintainers to understand what's going on

 4) even without knowing the implementation of DEFINE-INTERFACE and
    even without prior experience with it, one can make good guesses
    about what it does

 5) the GUI code is stunningly concise

Here is the GUI code alone:  

  < http://galoot.org/~bill/code/rss-reader/rss-gui.lisp >

Here is a screenshot of the application in development:

  < http://galoot.org/~bill/code/rss-reader/development.png >

and two screenshots of the application in use

  < http://galoot.org/~bill/code/rss-reader/in%20action.png >
  < http://galoot.org/~bill/code/rss-reader/in%20action%202.png >

Here are the support files:

  < http://galoot.org/~bill/code/rss-reader/ >

Here is an OS X universal binary (run at your own risk; I've only
done very basic testing):

  < http://galoot.org/~bill/code/rss-reader/BarebonesRSS.app.tar.gz >

Enjoy.



More information about the Python-list mailing list