Lisp HUG Maillist Archive

LispWorks and web apps

One of the first things that I asked myself when I was trying out LW was
this: How do I develop web apps in LW?

In SLIME+SBCL, what I do is have a (system) startup script launch SBCL
that will load a CL file that will load the web app. I can then
connect to this CL instance from Emacs using M-x slime-connect. In
that way I am able to update the code for the web app anytime. How can
I achieve the same with LW?

As stated in the documentation, I could build a LW image without the
IDE. I could then use that LW image (is that right?) to load the web
app and connect to it via SLIME. But how do I do things in such a way
that I'll still be using the LW IDE?


-- 
Rommel M. Martinez <ebzzry@gmail.com>


Re: LispWorks and web apps

"Rommel Martinez" <ebzzry@gmail.com> writes:

> One of the first things that I asked myself when I was trying out LW was
> this: How do I develop web apps in LW?
As in every other lisp also ;-)
>
> In SLIME+SBCL, what I do is have a (system) startup script launch SBCL
> that will load a CL file that will load the web app. I can then
> connect to this CL instance from Emacs using M-x slime-connect. In
> that way I am able to update the code for the web app anytime. How can
> I achieve the same with LW?
>
> As stated in the documentation, I could build a LW image without the
> IDE. I could then use that LW image (is that right?) to load the web
> app and connect to it via SLIME. But how do I do things in such a way
> that I'll still be using the LW IDE?
I think one can see it in a different way. e.g you can first develop
your Web application from within the LW IDE. Then while going into
"production" you just can build a LW image without the IDE stuff and
then you proceed as you'd do with Slime.

Depending on your server you even can stick to the graphical ui, but
usually that is not running on servers. Howerver you still can use the
gui-less image, and use scrren + ssh for connecting to the machine. 

You simply can run a a console emacs on your server and then you do a 
screen -r while looged int via ssh 
and you can do your work in the slime+emacs combo.

AFAIKT there are at least 4-5 options for web development, among
others
1) ucw http://common-lisp.net/project/ucw/
2) BKNR http://bknr.net/html/getting.html
3) AllegroServer + Webactions somewhere on the www.franz.com pages
4) The Edi Ware
5) Cl-HTTP 


I'm sorry if I missed a few. My best experiences have been with 3. I
never tried 4 but because it was developed by Edi Weitz I'd expect it
simply to work ;-)

I wrote  a somwhat lenghty tutorial about UCW, but could never really
familiarize myself with it. It's overly complex IMHO

CL-HTTP is very lispy solution. You don't write HTML in it you write
everythign in lisp. One can compare it in that regard much more with
Seaside.

AFAIKT is the BKNR stuff, AllegroServe + WebAction and Edi-Ware a much
more traditoinal MVC programming model. You wrote some code with
embedded Lisp the logic in Lisp and the backend with whatever you
like.

I for my part think that Ruby, and Smalltalk have a nicer programming
model and style as any of the Lisp solutions.... however YMMV of
course ;-)

Regards
Friedrich





Re: LispWorks and web apps


Am 24.04.2008 um 12:09 schrieb Rommel Martinez:

>
> One of the first things that I asked myself when I was trying out LW  
> was
> this: How do I develop web apps in LW?
>
> In SLIME+SBCL, what I do is have a (system) startup script launch SBCL
> that will load a CL file that will load the web app. I can then
> connect to this CL instance from Emacs using M-x slime-connect. In
> that way I am able to update the code for the web app anytime. How can
> I achieve the same with LW?
>
> As stated in the documentation, I could build a LW image without the
> IDE. I could then use that LW image (is that right?) to load the web
> app and connect to it via SLIME. But how do I do things in such a way
> that I'll still be using the LW IDE?

You would develop with the IDE and then you would deploy with  
delivered applications.
The IDE costs money. For the developer and user the good message is that
a) LispWorks has extensive support to create applications and b) that
there are no fees involved when you deliver your applications.

(Additionally you could buy development licenses for your production  
systems.
This would allow you to use the full development environment on those.
Often this is not necessary. Sometimes not even useful.)

This means that you develop your web applications with your development
environment as far as you get. You can then create an application that
for example can load additional code at runtime. But basically the
application will already contain some or more code of your web  
application.
Make yourself familiar with the mechanisms that LispWorks offers to
create such applications. So its easy to generate an application
that will be started by a script on boot time of some machine or
when you execute some start script. This application could for example
be started within screen and/or emacs, so that you could get a terminal
access to that application (which then better should be running some
kind of command loop).

If you run a delivered LispWorks application you should have two ways
to modify/extend it: a) you can use the Lisp interpreter (usually the
compiler is not part of the application, unless you have a special
license) and b) you can compile code on a similar platform with
the LispWorks IDE and then load the compiled code into the running
application. Make sure you read the docs and see what facilities
can be made available for a delivered application (one can also
see the other side: which facilities can be removed from Lisp, so that
you get a minimal application). Your applications can be without GUI  
(then
you might want start multi-processing later) and with GUI. Sometimes
it might make sense to have a kind of GUI-based control
interface.



>
>
>
> -- 
> Rommel M. Martinez <ebzzry@gmail.com>


Re: LispWorks and web apps

On Thu, 24 Apr 2008 14:08:17 +0200, Rainer Joswig <joswig@lisp.de> wrote:

> If you run a delivered LispWorks application you should have two
> ways to modify/extend it: a) you can use the Lisp interpreter
> (usually the compiler is not part of the application, unless you
> have a special license)

The compiler is part of delivered applications; only the function
COMPILE-FILE is removed.  See 1.2.2 of the Delivery User Guide and the
:REDEFINE-COMPILER-P keyword argument to the delivery function.


Re: LispWorks and web apps

On Thu, 24 Apr 2008 15:49:12 +0200, Rainer Joswig <joswig@lisp.de> wrote:

> But it still would mean that a source file that gets loaded into a
> delivered LispWorks app would not get compiled or is that a way to
> enforce that?

No, I don't think you can enforce that unless you read the forms in
the file yourself and compile them piecemeal using COMPILE.  But of
course you know that the semantics of this are different from
COMPILE-FILE.


Re: LispWorks and web apps

Rainer Joswig <joswig@lisp.de> writes:

> But it still would mean that a source file that gets loaded into a  
> delivered LispWorks app
> would not get compiled or is that a way to enforce that?

IMHO, this is not a big deal, when I patch production servers, I do
this with tested code. Usually I collect the patches in a file which
is compiled, so the production server loads a fasl file which has
already been tested to work.  For very simple function redefintions or
emergency patches, I quite often just add a (compile (defun ...)) to
the running server.

-- 
  (espen)


Re: LispWorks and web apps

    I use LW with portableaserve from Allegro.
I'm a very big fan of how well this works,
especially when there are bugs.  Since
the server program errors go right to the LW IDE debugger,
I can graphically crawl and inspect the stack
and even patch the actual code in the IDE on top of the actual data
and resubmit the html requests immediately thereafter.
Because of this simplicity,  I almost never have to write test driver  
code;
instead of test driver code I just cache global pointers to recent web
request data structures and resubmit them to server functions,
in order to do unit and system tests.

Lawrence Au
laau@erols.com


On Apr 24, 2008, at 6:09 AM, Rommel Martinez wrote:

>
> One of the first things that I asked myself when I was trying out LW  
> was
> this: How do I develop web apps in LW?
>
> In SLIME+SBCL, what I do is have a (system) startup script launch SBCL
> that will load a CL file that will load the web app. I can then
> connect to this CL instance from Emacs using M-x slime-connect. In
> that way I am able to update the code for the web app anytime. How can
> I achieve the same with LW?
>
> As stated in the documentation, I could build a LW image without the
> IDE. I could then use that LW image (is that right?) to load the web
> app and connect to it via SLIME. But how do I do things in such a way
> that I'll still be using the LW IDE?
>
>
> -- 
> Rommel M. Martinez <ebzzry@gmail.com>
>


Re: LispWorks and web apps

On Thu, Apr 24, 2008 at 6:09 PM, Rommel Martinez <ebzzry@gmail.com> wrote:
> One of the first things that I asked myself when I was trying out LW was
>  this: How do I develop web apps in LW?
>
>  In SLIME+SBCL, what I do is have a (system) startup script launch SBCL
>  that will load a CL file that will load the web app. I can then
>  connect to this CL instance from Emacs using M-x slime-connect. In
>  that way I am able to update the code for the web app anytime. How can
>  I achieve the same with LW?
>
>  As stated in the documentation, I could build a LW image without the
>  IDE. I could then use that LW image (is that right?) to load the web
>  app and connect to it via SLIME. But how do I do things in such a way
>  that I'll still be using the LW IDE?
>
>
>  --
>  Rommel M. Martinez <ebzzry@gmail.com>
>

Thank you for all the responses. Having read all that, I made a
summary of what I learned regarding deploying web applications using
LispWorks. Please correct me if I am wrong.

So the usual cycle when deploying web applications using LispWorks is
the following:

* Write, test, debug the code using the IDE, as far I could get, as
  what Rainer has said.

* Deliver the application. This could mean either:

  a) Write a (startup) script that would launch the application. It
     would look something the following:

     screen -d -m -S foo lispworks-no-gui -init foo.lisp

     And foo.lisp would contain something like:

     (foo:start :port 8080)

  b) Use the DELIVER functionality of LispWorks

* To update the code of the application, I would open the source
  file(s) in the LispWorks IDE, then proceed with the usual
  write-test-debug cycle.

* Test the "updated" code, with something like the following:

  $ lispworks-no-gui -init foo2.lisp

  foo2.lisp would contain something like:

  (foo2:start :port 8181)

* Once I'm satisfied with the changes, I would load the "patches" to
  the running application, making sure first that I've made the
  necessary changes to adjust to the "production" version (e.g.: port
  numbers)

  $ screen -r foo
  CL-USER> (load (compile-file #P"/path/to/patches/..."))

  OR

  CL-USER> (asdf :foo)

Where have I gone wrong? What should I change? Am I doing things
contra to the "LispWorks" way of doing things?

At the moment, when I'm deploying web applications using SBCL (just to
give you an idea of what I want to achieve) is the following:

* Run SBCL with Swank. The file .sbclrc would contain something like
  the following:

  (require :asdf)
  (require :swank)
  (swank:create-server ...)

* Using SLIME, I would then connect to that SBCL instance:

  M-x slime-connect RET RET

* Write-test-debug

* Deploy application using a script (or something equivalent)

  sbcl --no-sysinit --no-userinit --load foo.lisp

  foo.lisp would contain:

  (require :asdf)
  (require :swank)
  (swank:create-server :port 4105 ...)
  (require :foo)
  (foo:start :port 8080 ...)

* I would then access the application at http://localhost:8080

* To update the code in the application, I would connect to it using
  SLIME:

  M-x slime-connect RET 4105 RET

These steps assume that the ASDF system FOO has properly been setup
(symlinks, etc).

How would I achieve something like that in LispWorks?

-- 
Rommel M. Martinez <ebzzry@gmail.com>


Updated at: 2020-12-10 08:43 UTC