From: David Bakhash
Subject: CL CGIs
Date: 
Message-ID: <cxj1zq4oh6z.fsf@engc.bu.edu>
hey,

I used to write CGI scripts when I worked for MIT LL.  I hated having
to do everything in Perl, but now I'm wondering if people do any of
this stuff in CL.  It seems like the ultimate way to deal with CGI,
provided you have a Lisp process running all the time.  Anyone do it
that way?  examples of CGI scripts I can visit that are written in
Lisp?  Any cgi libraries in CL?

dave

From: Steve Gonedes
Subject: Re: CL CGIs
Date: 
Message-ID: <m2g1ekzcuh.fsf@KludgeUnix.com>
David Bakhash <·····@bu.edu> writes:

< hey,
< 
< I used to write CGI scripts when I worked for MIT LL.  I hated having
< to do everything in Perl, but now I'm wondering if people do any of
< this stuff in CL.  It seems like the ultimate way to deal with CGI,
< provided you have a Lisp process running all the time.  Anyone do it
< that way?  examples of CGI scripts I can visit that are written in
< Lisp?  Any cgi libraries in CL?

Have you ever heard of meta-html? The author(s) claim that it is not
lisp, but it looks very similiar. Maybe it'll work for you. It comes
with a server/interpreter/etc..., and plugs into apache and what not
as well.

http://www.metahtml.com/
From: Rob Warnock
Subject: Re: CL CGIs
Date: 
Message-ID: <6s02sk$1qn5a@fido.engr.sgi.com>
David Bakhash  <·····@bu.edu> wrote:
+---------------
| I used to write CGI scripts when I worked for MIT LL.  I hated having
| to do everything in Perl, but now I'm wondering if people do any of
| this stuff in CL.  It seems like the ultimate way to deal with CGI,
| provided you have a Lisp process running all the time.  Anyone do it
| that way?  examples of CGI scripts I can visit that are written in Lisp?
| Any cgi libraries in CL?
+---------------

Not CL, but Scheme. See http://people.delphi.com/gjc/siod.html

Also see the Shriram Krishnamurthi's "cgi.ss" library
    http://www.cs.rice.edu/~shriram/Shriram/Libraries/
or in "plt/collects/net/cgi.ss" in the MzScheme distribution:
    http://www.cs.rice.edu/CS/PLT/packages/mzscheme/

Hmmm... There may be some CL CGI stuff in CL-HTTP...
http://www.ai.mit.edu/projects/iiip/doc/cl-http/home-page.html


-Rob

-----
Rob Warnock, 7L-551		····@sgi.com   http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
2011 N. Shoreline Blvd.		FAX: none (temp)
Mountain View, CA  94043	PP-ASEL-IA
From: Jeff Dalton
Subject: Re: CL CGIs
Date: 
Message-ID: <904111222.27985.0.nnrp-11.9e984eab@news.demon.co.uk>
In article <···············@engc.bu.edu>, David Bakhash  <·····@bu.edu> wrote:
>hey,
>
>I used to write CGI scripts when I worked for MIT LL.  I hated having
>to do everything in Perl, but now I'm wondering if people do any of
>this stuff in CL.

Yes, I do.  I have a number of CGI programs in Lisp, and some of them
start an HTTP server, also (mostly) in Lisp.  (There is also, of course,
CL-HTTP.)

>  It seems like the ultimate way to deal with CGI,
>provided you have a Lisp process running all the time. 

You don't have to have a Lisp running all the time.  It can start
running when a CGI request is made.

-- jd
From: David Bakhash
Subject: Re: CL CGIs
Date: 
Message-ID: <cxj7lzvoagp.fsf@engc.bu.edu>
····@interactive.co.uk (Jeff Dalton) writes:

> >  It seems like the ultimate way to deal with CGI,
> >provided you have a Lisp process running all the time. 
> 
> You don't have to have a Lisp running all the time.  It can start
> running when a CGI request is made.

yes, but that seems expensive.  restarting Lisp (at least with the
implementation I use) is a time-consuming thing.

dave
From: Steve Gonedes
Subject: Re: CL CGIs
Date: 
Message-ID: <m2ww7v5ckp.fsf@KludgeUnix.com>
David Bakhash <·····@bu.edu> writes:

< yes, but that seems expensive.  restarting Lisp (at least with the
< implementation I use) is a time-consuming thing.

Have you thought about having a lisp process establish itself as a
unix daemon - perhaps using sockets? You could then have it start a
new process for each CGI script you wanted to run. You might even
dedicate an entire image to procesess spawning - something like a `CGI
server' I guess.

Maybe you could post what you decide - it sounds like an interesting
problem...
From: Kelly Murray
Subject: Re: CL CGIs
Date: 
Message-ID: <35E4E60E.679299E9@IntelliMarket.Com>
My approach is to use a CL-based web server
that is always running.  To run CL "CGIs" from another non-lisp
web server (e.g. apache),  I use a tiny stub CGI program
that essentially operates as a proxy for the Lisp web server,
forwarding the HTTP requests to the lisp server,
and sending the replies back through the non-lisp server.

Steve Gonedes wrote:
> 
> David Bakhash <·····@bu.edu> writes:
> 
> < yes, but that seems expensive.  restarting Lisp (at least with the
> < implementation I use) is a time-consuming thing.
> 
> Have you thought about having a lisp process establish itself as a
> unix daemon - perhaps using sockets? You could then have it start a
> new process for each CGI script you wanted to run. You might even
> dedicate an entire image to procesess spawning - something like a `CGI
> server' I guess.
> 
> Maybe you could post what you decide - it sounds like an interesting
> problem...
From: Eric Marsden
Subject: Re: CL CGIs [off-topic]
Date: 
Message-ID: <m2iujezm0b.fsf_-_@cook.onecert.fr>
>>>>> "KM" == Kelly Murray <···@IntelliMarket.Com> writes:

  KM> My approach is to use a CL-based web server that is always
  KM> running. To run CL "CGIs" from another non-lisp web server (e.g.
  KM> apache), I use a tiny stub CGI program that essentially operates
  KM> as a proxy for the Lisp web server, forwarding the HTTP requests
  KM> to the lisp server, and sending the replies back through the
  KM> non-lisp server.

Apache has this functionality built in. Use the mod_proxy module to
map a region of your webspace (/lisp, say), to your secondary server
running on another port. Here are the appropriate directives if anyone
is interested:

   LoadModule proxy_module /usr/lib/apache/1.3/libproxy.so
   ProxyRequests On
   ProxyPass /lisp/ http://my.domain.com:8001/

More information at http://www.apache.org/docs/mod/mod_proxy.html
   
-- 
Eric Marsden
emarsden @ mail.dotcom.fr
It's elephants all the way down
From: Kelly Murray
Subject: Re: CL CGIs [off-topic]
Date: 
Message-ID: <35E639C9.41C1107@IntelliMarket.Com>
The CGI stub solution is portable to different servers,
and it gives the chance to fiddle with the URLs before passing them on,
but thanks for the cool tip for apache,
I didn't know it could do this.   I may try it.
With apache, you could even build-in the entire lisp with ACL5,
but there is not much reason to invest the effort IMO.

 -- Kelly Murray


Eric Marsden wrote:
> 
> >>>>> "KM" == Kelly Murray <···@IntelliMarket.Com> writes:
> 
>   KM> My approach is to use a CL-based web server that is always
>   KM> running. To run CL "CGIs" from another non-lisp web server (e.g.
>   KM> apache), I use a tiny stub CGI program that essentially operates
>   KM> as a proxy for the Lisp web server, forwarding the HTTP requests
>   KM> to the lisp server, and sending the replies back through the
>   KM> non-lisp server.
> 
> Apache has this functionality built in. Use the mod_proxy module to
> map a region of your webspace (/lisp, say), to your secondary server
> running on another port. Here are the appropriate directives if anyone
> is interested:
> 
>    LoadModule proxy_module /usr/lib/apache/1.3/libproxy.so
>    ProxyRequests On
>    ProxyPass /lisp/ http://my.domain.com:8001/
> 
> More information at http://www.apache.org/docs/mod/mod_proxy.html
> 
> --
> Eric Marsden
> emarsden @ mail.dotcom.fr
> It's elephants all the way down
From: Mikael MC Cardell
Subject: Re: CL CGIs
Date: 
Message-ID: <svpvdmqcwl.fsf@sally.lysator.liu.se>
Steve Gonedes <········@worldnet.att.net> writes:

> Have you thought about having a lisp process establish itself as a
> unix daemon - perhaps using sockets?

I know about CL-HTTP, but what about something like Apache's Fast CGI
where you link the interpreter of your choice to the HTTP server? We
have been doing it with Python, a really nice language, but I would
like to experiment with Scheme or CL as well. Has anyone allready done
that?

-- 
Mikael "MC" Cardell <··@hack.org>
Hacking and Computing Knowledge
We fight for free software!
From: Dimitrios Souflis
Subject: Re: CL CGIs
Date: 
Message-ID: <35E67C5B.6E71058C@altera.gr>
Mikael MC Cardell wrote:

> I know about CL-HTTP, but what about something like Apache's Fast CGI
> where you link the interpreter of your choice to the HTTP server? We
> have been doing it with Python, a really nice language, but I would
> like to experiment with Scheme or CL as well. Has anyone allready done
> that?

I didn't follow the discussion on comp.lang.lisp, but I
understand you are looking for experiences with external/internal
CGI in Lisp/Scheme. Well, for one thing, have a look at
    http://www-swiss.ai.mit.edu/scsh/
a Web server in SCSH.
For another, have a look at
    http://www.altera.gr/lnews.html
for an announcement for Altera SQL Server v2.0, due September.
A (reentrant) Scheme interpreter (TinyScheme, see my homepage
below for details and download) is integrated to the SQL/HTTP
server, and can be used in two ways (copying from a similar
posting of mine to this newsgroup):

    1) Server-side scripts, a la server-side Javascript.
    Any file ending in .scm will be executed by the Scheme interpreter
    and its output is fed to the client. Like CGI output, only no
    separate process is involved.

    2) URL handlers.
    Our server features persistent HTTP sessions. During such a session,
    portions of the Webspace (e.g. everything under /traid/buy) can be
    handled by Scheme scripts that retain state from invocation to
    invocation. This will allow HTML applications (with or without
    use of SQL).

Form data is "plugged" in the Scheme environment before each
invocation. I don't know the content of the original posting,
but in case you're interested, TinyScheme is free, it's a
single C module <4000 lines long, and it's geared towards
standalone *and* scripting use.

Ah, yes. To anyone interested: TinyScheme now features full
R5RS I/O + string ports.

--
Dimitrios Souflis                ········@altera.gr
Altera Ltd.                      http://www.altera.gr/dsouflis

*** Reality is what refuses to disappear when you stop believing
*** in it (VALIS, Philip K. Dick)
From: Jeff Dalton
Subject: Re: CL CGIs
Date: 
Message-ID: <x2soihgd49.fsf@gairsay.aiai.ed.ac.uk>
Mikael MC Cardell <··@hack.org> writes:

> Steve Gonedes <········@worldnet.att.net> writes:
> 
> > Have you thought about having a lisp process establish itself as a
> > unix daemon - perhaps using sockets?
> 
> I know about CL-HTTP, but what about something like Apache's Fast CGI
> where you link the interpreter of your choice to the HTTP server? We
> have been doing it with Python, a really nice language, but I would
> like to experiment with Scheme or CL as well. Has anyone allready done
> that?

Humm.  I'm surprised that such things make much difference -- at 
least for ordinary web sites and on machines that have enough memory.
(Probably some people have to deal with so many "hits" that every
little buit helps, but most of us are not in that boat.)

On reasonably fast machines (such as new-ish PCs) you can start
thousands of Unix processes a second.  The number of context-switches
per second (between Unix processes) is fairly huge.

That something is a separate process, rather than linked in,
does not mean that using it has to be slow.

-- jd
From: Jeff Dalton
Subject: Re: CL CGIs
Date: 
Message-ID: <x2u32xgdml.fsf@gairsay.aiai.ed.ac.uk>
Steve Gonedes <········@worldnet.att.net> writes:

> David Bakhash <·····@bu.edu> writes:
> 
> < yes, but that seems expensive.  restarting Lisp (at least with the
> < implementation I use) is a time-consuming thing.
> 
> Have you thought about having a lisp process establish itself as a
> unix daemon - perhaps using sockets? You could then have it start a
> new process for each CGI script you wanted to run. You might even
> dedicate an entire image to procesess spawning - something like a `CGI
> server' I guess.

One thing I do for some purposes is to have a Lisp CGI program start a
Lisp HTTP server.  Other sorts of socket-listening Lisp programs could
be started just as easily; and if startup time is really a problem, it
could be a non-Lisp CGI program that starts the socket-listening Lisp.

It's also possible for a CGI program to see if a server is running and
start one if not.

Then, there are a couple of ways a server can be used once it exists.

But you don't need to work all that out before you can write
some Lisp CGI programs!

-- jd
From: Jeff Dalton
Subject: Re: CL CGIs
Date: 
Message-ID: <x2vhndgean.fsf@gairsay.aiai.ed.ac.uk>
David Bakhash <·····@bu.edu> writes:

> ····@interactive.co.uk (Jeff Dalton) writes:
> 
> > >  It seems like the ultimate way to deal with CGI,
> > >provided you have a Lisp process running all the time. 
> > 
> > You don't have to have a Lisp running all the time.  It can start
> > running when a CGI request is made.
> 
> yes, but that seems expensive.  restarting Lisp (at least with the
> implementation I use) is a time-consuming thing.

I often use GCL which doesn't take long to start on the machines
I use.  Moreover, even bigger Lisps will often *re*start quickly
if they've been run recently.  Also, the slow cases are when
lots of stuff must be paged in, and that can happen for a Lisp
that's been running (but idle for some time), just as it can for
a Lisp just starting up.

-- jd
From: Tim Bradshaw
Subject: Re: CL CGIs
Date: 
Message-ID: <ey3u32shxls.fsf@todday.aiai.ed.ac.uk>
* Jeff Dalton wrote:

> I often use GCL which doesn't take long to start on the machines
> I use.  Moreover, even bigger Lisps will often *re*start quickly
> if they've been run recently.  Also, the slow cases are when
> lots of stuff must be paged in, and that can happen for a Lisp
> that's been running (but idle for some time), just as it can for
> a Lisp just starting up.

For what it's worth I did a *very naive* test on some Lisps we have
here.  All of these are for runs after the first on a Sun E150 which
is a 170MHz machine, with enough memory that everything should be
paged in.

These are very naive (I know I've said that, but I want to stress it!)
tests of running Lisp images which immediately exit.

Liquid 5.0.3: echo "(QUIT)" | lcl >/dev/null

	0.27 secs (average of 10 runs)

CMUCL 18a: echo "(QUIT)" | cmucl -noinit >/dev/null

	0.21 secs (10 runs)

Allegro CL 4.3: cl -qq -e "(exit)" >/dev/null

	0.29 sec (10 runs)

gcl 2.2.2: echo "(bye)" | gcl

	0.04 secs

perl 5.004: time perl -e "exit;"

	0.04 secs

sh: time sh -c exit

	0.02 secs

So it seems like totally naive runs of various commercial Lisps are ~
5x as slow as perl to start, but not in fact particularly slow.  I
suspect that saving an image which did less of the hairy interactive
init stuff would be much faster.  gcl is as fast as perl to start.

--tim
From: Pierre Mai
Subject: Re: CL CGIs
Date: 
Message-ID: <m3r9y437zt.fsf@dent.isdn.cs.tu-berlin.de>
David Bakhash <·····@bu.edu> writes:

> I used to write CGI scripts when I worked for MIT LL.  I hated having
> to do everything in Perl, but now I'm wondering if people do any of
> this stuff in CL.  It seems like the ultimate way to deal with CGI,
> provided you have a Lisp process running all the time.  Anyone do it
> that way?  examples of CGI scripts I can visit that are written in
> Lisp?  Any cgi libraries in CL?

The standard answer here is, of course, CL-HTTP (see
http://www.ai.mit.edu/projects/iiip/doc/cl-http/home-page.html), which
is the MIT's Hypermedia Server.  If you are a member of ACM's Digital
Library, or have access to a nice library, you can also search there
for a "recent" issue of Communications of the ACM, which contains a
nice article about the use of CL-HTTP at a major semi-conductor
plant...

Regs, Pierre.

-- 
Pierre Mai <····@cs.tu-berlin.de>	http://home.pages.de/~trillian/
  "Such is life." -- Fiona in "Four Weddings and a Funeral" (UK/1994)
From: David Bakhash
Subject: Re: CL CGIs
Date: 
Message-ID: <cxj90kboai1.fsf@engc.bu.edu>
Pierre Mai <····@dent.isdn.cs.tu-berlin.de> writes:

> David Bakhash <·····@bu.edu> writes:
> 
> > I used to write CGI scripts when I worked for MIT LL.  I hated having
> > to do everything in Perl, but now I'm wondering if people do any of
> > this stuff in CL.  It seems like the ultimate way to deal with CGI,
> > provided you have a Lisp process running all the time.  Anyone do it
> > that way?  examples of CGI scripts I can visit that are written in
> > Lisp?  Any cgi libraries in CL?
> 
> The standard answer here is, of course, CL-HTTP (see

I wasn't even asking about the server, though.  I was asking about the 
libraries that would be useful for writing CGI scripts.  I guess
CL-HTTP has that too.  thanks.

dave