From: Ryan
Subject: Starting LISP
Date: 
Message-ID: <JVjs6.3648$GD.2040858@typhoon.snet.net>
Hey all,

I've always been interested in LISP and I'd like to learn at least a little.
I'm really a scripter at heart (I know PHP, ASP, ColdFusion, some Perl and a
bit of Python)
and am wondering, after reading the lisp.org FAQ, what LISP's place in the
computer world
really is. The FAQ was very vague... What are the common, everyday uses of
LISP for
those that use it professionally?

Also --- any links or recommendations to books/tutorials that teach LISP
mindset, i.e.
"Thinking in LISP" would be appreciated. Boy, the syntax is a bit of a kick
in the pants
at first...

P.S. - Yes, technically I'm a lowly uber-high-level web developer; but I've
always had
respect for the hardcore Unix programmers.

--
Ryan Flynn
Practical web development/design
www.ryanflynn.com

From: Bob Bane
Subject: Re: Starting LISP
Date: 
Message-ID: <3AB23313.A4A8931C@removeme.gst.com>
Ryan wrote:
> 
> ... What are the common, everyday uses of
> LISP for
> those that use it professionally?

Those of us who can justify it use it wherever we can.  The
justifications that have worked the best for me in the past are:

* the problem is ill-specified, has a researchy component, or will
likely have to be modified in the field.  Dynamic languages in general
and Lisp in particular win big here.

* the solution must have unusually high reliability.  Lisp's attention
to detail in arithmetic, storage management, exception handling, etc.
rules here.

> Also --- any links or recommendations to books/tutorials that teach LISP
> mindset, i.e.
> "Thinking in LISP" would be appreciated.

Check the references section of the FAQ.  Highly recommended (by me) are
books by Norvig and Graham.

> ... Boy, the syntax is a bit of a kick
> in the pants
> at first...

With luck, you will eventually see that by choosing a simple, regular
syntax, Lisp frees you as a developer to concentrate on the semantics. 
Code that writes code that writes code sounds scary, but automatic code
generation saves time and grief.

> P.S. - Yes, technically I'm a lowly uber-high-level web developer; but I've
> always had
> respect for the hardcore Unix programmers.

There has been a lot of action recently with Lisp for web development. 
I've personally played with CL-HTTP, done a bit more with AllegroServe
and its htmlgen stuff, and there's a lot more outside of those two.

-- 
Remove obvious stuff to e-mail me.
Bob Bane
From: Thaddeus L Olczyk
Subject: Reflective programming--show me the money (Re: Starting LISP)
Date: 
Message-ID: <3ab35c5d.398269171@nntp.interaccess.com>
On Fri, 16 Mar 2001 10:36:51 -0500, Bob Bane <····@removeme.gst.com>
wrote:

>Code that writes code that writes code sounds scary, but automatic code
>generation saves time and grief.
OK I'm in the middle of one of my sojourns into LISP.
I often hear that reflective programming is very effective.
But whenever I look at it ( admittedly in the limited time I have ),
I've always failed to see what techniques produce such spectacular
results ( I've seen some advantages yes, but they don't seem that
great to me ).  I feel there is truth in the statement, but that
people are so focused on the statement, that we never see the true
advantages.

Can anyone give me examples of ( a few simple ) programs that
are written nonreflectively and are then rewritten reflectively?
Keep in mind that I'm not some manager who is happy to
see some study which says: "We wrote this system and had these
problems. Later we went back and rewrote these systems using ...
and found significant benefit...". Instead show me some code that
demonstrates how reflective programming can improve a system.
From: Alain Picard
Subject: Re: Reflective programming--show me the money (Re: Starting LISP)
Date: 
Message-ID: <86y9u362n6.fsf@gondolin.i-did-not-set--mail-host-address--so-shoot-me>
>>>>> Thaddeus L Olczyk writes:

TLO> I often hear that reflective programming is very effective.
TLO> But whenever I look at it ( admittedly in the limited time I have ),
TLO> I've always failed to see what techniques produce such spectacular
TLO> results
[snip]

TLO> Can anyone give me examples of ( a few simple ) programs that

I can't give you examples of "simple programs written
non-reflectively", but take a look at PLOB!.  It implements
an object database persistency layer, by making extensive use
of the MOP and reflection.  The degree of transparency obtained
is IMO phenomenal, especially if you've ever used something like
VERSANT/C++, which forces you to essentially write all of your
code in a manner which tightly couples it to the DB.


-- 
It would be difficult to construe        Larry Wall, in  article
this as a feature.			 <·····················@netlabs.com>
From: Thaddeus L Olczyk
Subject: Re: Reflective programming--show me the money (Re: Starting LISP)
Date: 
Message-ID: <3ab5fd05.93107406@nntp.interaccess.com>
On Sun, 18 Mar 2001 05:35:11 GMT, Alain Picard
<·······@optushome.nospamplease.com.au> wrote:

>>>>>> Thaddeus L Olczyk writes:
>
>TLO> I often hear that reflective programming is very effective.
>TLO> But whenever I look at it ( admittedly in the limited time I have ),
>TLO> I've always failed to see what techniques produce such spectacular
>TLO> results
>[snip]
>
>TLO> Can anyone give me examples of ( a few simple ) programs that
>
>I can't give you examples of "simple programs written
>non-reflectively", but take a look at PLOB!.  It implements
>an object database persistency layer, by making extensive use
>of the MOP and reflection.  The degree of transparency obtained
>is IMO phenomenal, especially if you've ever used something like
>VERSANT/C++, which forces you to essentially write all of your
>code in a manner which tightly couples it to the DB.
Do you have a URL?
From: Erik Winkels
Subject: Re: Reflective programming--show me the money (Re: Starting LISP)
Date: 
Message-ID: <87k85mop6w.fsf@xs4all.nl>
http://www.google.com/search?q=plob+lisp

First result or press "I'm Feeling Lucky".
From: Heiko Kirschke
Subject: Re: Reflective programming--show me the money (Re: Starting LISP)
Date: 
Message-ID: <ug0g7a6my.fsf@ovivo.de>
······@interaccess.com (Thaddeus L Olczyk) writes:

> On Sun, 18 Mar 2001 05:35:11 GMT, Alain Picard
> <·······@optushome.nospamplease.com.au> wrote:
> >take a look at PLOB!.  It implements
> >an object database persistency layer, by making extensive use
> >of the MOP and reflection.

> Do you have a URL?

http://www.lisp.de/software/plob

-- 
Viele Gruesse,
Heiko Kirschke
From: Bob Bane
Subject: Re: Reflective programming--show me the money (Re: Starting LISP)
Date: 
Message-ID: <3AB6279C.396A3DE7@removeme.gst.com>
Thaddeus L Olczyk wrote:
> 
> On Fri, 16 Mar 2001 10:36:51 -0500, Bob Bane <····@removeme.gst.com>
> wrote:
> 
> >Code that writes code that writes code sounds scary, but automatic code
> >generation saves time and grief.
> 
> Can anyone give me examples of ( a few simple ) programs that
> are written nonreflectively and are then rewritten reflectively?

The shortest answer I can give you is:

http://www.norvig.com/design-patterns/index.htm

where Norvig makes the case that most of the stuff in the design
patterns literature is better handled by using languages that support
real macros, first-class types and functions, etc.

The standard macro example in Lisp is (WITH-OPEN-FILE ...).  Everyone
knows the most bulletproof way to handle file I/O is something like
this:

(let ((filehandle nil))
   (unwind-protect
      (progn
         (setq filehandle (open filename))
         (mung-file filehandle))
      (if filehandle (close filehandle))))

i.e. insure that if an exception gets signaled while processing the
file, the file gets closed.

Any language that supports exceptions can do this.  In languages without
macros, the syntactic baggage in setting up the exception handler is at
least as painful as the above (like Java's try-catch-finally), so
programmers get lazy and don't do it consistently.  In Lisp, all that
cruft gets buried once and for all as:

(with-open-file
   (filehandle filename)
  (mung-file filehandle))

where WITH-OPEN-FILE is a macro that expands into the code above.

This is just use of macros for straightforward abbreviation of code. 
Anybody got a small example of macros that examine their arguments and
generate better code as a result?

-- 
Remove obvious stuff to e-mail me.
Bob Bane
From: Raymond Wiker
Subject: Re: Reflective programming--show me the money (Re: Starting LISP)
Date: 
Message-ID: <861yrtaguk.fsf@raw.grenland.fast.no>
Bob Bane <····@removeme.gst.com> writes:

> This is just use of macros for straightforward abbreviation of code. 
> Anybody got a small example of macros that examine their arguments and
> generate better code as a result?

        The HyperSpec entry for define-compiler-macro, perhaps?

-- 
Raymond Wiker
·············@fast.no
From: Hannah Schroeter
Subject: Re: Reflective programming--show me the money (Re: Starting LISP)
Date: 
Message-ID: <995ra7$r2h$1@c3po.schlund.de>
Hello!

In article <·················@removeme.gst.com>,
Bob Bane  <····@removeme.gst.com> wrote:
>[...]

>This is just use of macros for straightforward abbreviation of code. 
>Anybody got a small example of macros that examine their arguments and
>generate better code as a result?

You could also do things for which you have to run separate preprocessors
in other languages with Lisp macros, such as scanner/parser generating.

I don't know if there's really such a thing, but something like

(define-lexer c-like-lexer
 ("int" (return 'token:int))
 ("char" (return 'token:char))
 ...
 ("." (return '(token:unknown-char (char lexer-text 0)))))

defining a function

(defun c-like-lexer (stream) ...), which returns the lexer function,
to be used like this:

(let* ((stdin-lexer (c-like-lexer *standard-input))
       (first-token (funcall stdin-lexer)))
 ...)

could be interesting, couldn't it?

Kind regards,

Hannah.
From: Paolo Amoroso
Subject: Re: Starting LISP
Date: 
Message-ID: <Az2yOh7dMJp09gBpcX0F9grnhnaI@4ax.com>
On Fri, 16 Mar 2001 03:09:29 -0500, "Ryan" <····@ryanflynn.com> wrote:

> I've always been interested in LISP and I'd like to learn at least a little.

Here is some introductory online material:

  Successful Lisp
  http://psg.com/~dlamkins/sl/sl.html

  Basic Lisp Techniques
  http://www.franz.com/resources/educational_resources/cooper.book.pdf

  Common Lisp: A Gentle Introduction to Symbolic Computation
  http://www.cs.cmu.edu:80/afs/cs.cmu.edu/user/dst/www/LispBook/index.html

Another useful resource is:

  CLiki
  http://ww.telent.net/cliki/


> and am wondering, after reading the lisp.org FAQ, what LISP's place in the
> computer world
> really is. The FAQ was very vague... What are the common, everyday uses of
> LISP for
> those that use it professionally?

Other users more experienced than me will probably comment on this. I'd
only like to point out that Common Lisp is a general-purpose programming
language designed for developing industrial strength applications.

So, a first order approximation to the answer to your question may be:
Lisp's place in the computer world is that of a general purpose language.
Although this seems obvious, I mention it because, while Lisp is often
recommended for certain specialized areas such as rapid prototyping or AI,
it is often forgotten that it also happens to be an excellent general
purpose language.


> Also --- any links or recommendations to books/tutorials that teach LISP
> mindset, i.e.
> "Thinking in LISP" would be appreciated. Boy, the syntax is a bit of a kick
> in the pants
> at first...

An advanced resource on this is the book:

  "On Lisp - Advanced Techniques for Common Lisp"
  Paul Graham
  Prentice Hall, 1994

Be sure to read "ANSI Common Lisp" (by the same author and publisher)
first.


> P.S. - Yes, technically I'm a lowly uber-high-level web developer; but I've

You should be able to find something interesting for you in the Web section
of CLiki (mentioned above), or join the Lispweb mailing list:

  http://www.red-bean.com/mailman/listinfo/lispweb

Have (de)fun,


Paolo
-- 
EncyCMUCLopedia * Extensive collection of CMU Common Lisp documentation
http://cvs2.cons.org:8000/cmucl/doc/EncyCMUCLopedia/
From: Tim Bradshaw
Subject: Re: Starting LISP
Date: 
Message-ID: <nkjn1aigd2z.fsf@tfeb.org>
"Ryan" <····@ryanflynn.com> writes:

> 
> Also --- any links or recommendations to books/tutorials that teach LISP
> mindset, i.e.
> "Thinking in LISP" would be appreciated. Boy, the syntax is a bit of a kick
> in the pants
> at first...
> 
> P.S. - Yes, technically I'm a lowly uber-high-level web developer; but I've
> always had
> respect for the hardcore Unix programmers.
> 

Well, if you're a web person, you're probably familiar with HTML/XML.
Think of Lisp's syntax as XML without the appalling verbosity:

	(if (foop x) x nil)

is something like (depends on your mapping of course, this is a very
lightweight one which is probably not good enough, and is *not* meant
to be taken seriously before someone niggles about it)

	<if><foop>x</foop> x nil</if>

Although no one would realistically want to write Lisp in XML, because
the syntax is just too awful, writing XML/HTML in Lisp is much more
interesting.  There are several systems for doing this, mine (which is
minimal, hacky and really HTML-only) lets you do stuff like:

(with-html-output (s)
  (:html (:head (:title "title"))
    ((:body :bgcolor "white")
      (:h1 "title")
      (:ul
        (dotimes (i 10)
          (htm (:li (fmt "Item ~D" i))))))))

Other systems are a load more sophisticated than mine, and do pretty
full XML support I think (the one that Franz have looks pretty good
(and is, I think, free) though I haven't tried it).  They all offer
the kind of near-seamless mix between markup and code that you see
here - in fact, in my system at least, the markup really *is* code --
the WITH-HTML-OUTPUT macro is really a little (little as in a
hundred-odd lines) compiler for this `LHTML' language which compiles
it into a lisp expression which produces the equivalent HTML.

I hate to say it but I'm writing a bunch of web pages at the moment,
and I'm actually writing them in this HTML representation because I
find it easier than writing HTML - mostly better editor support, but
than instant availability of a full programming language turns out to
be a huge win too.

--tim