Wednesday, June 25th, 2008
SymbolicWeb: Ajax and Comet with Lisp
<p>No matter how much Paul Graham talks about his Web success, we don't hear too often about Lisp-powered Web applications.SymbolicWeb is offering up a new type of framework to help change that.
SymbolicWeb aims to create a GUI framework similar to GTK+ and QT for Common Lisp. It differs in that it uses the browser to render the UI elements.
There are a slew of examples, such as this simple echo chat program:
-
;;;; http://nostdal.org/ ;;;;
(in-package #:sw)
(defparameter *max-chat-pane-size* 100)
(defapp chat-app (empty-page-app)
((input (mk-text-input))
(chat-pane :allocation :class (mk-container nil))))
(defuri chat-app "chat")
(defmethod main ((chat-app chat-app))
(with-slots (input chat-pane) chat-app
(setf (on-enterpress-of input
:callback-data `((:input-value . ,(js-code-of (value-of input)))) ;; Include some data when the event fires.
:js-after (js-code-of (setf (value-of input) ""))) ;; Clear the input field after the event has been fired and sent.
(lambda (&key input-value)
(prepend (mk-span (escape-for-html input-value) :display "block")
chat-pane)
;; Don't let it grow too big; delete some chat history.
(when (> (length (children-of chat-pane)) *max-chat-pane-size*)
(dolist (span (subseq (children-of chat-pane) *max-chat-pane-size*))
(remove span)))))
(add-to *root*
(mk-span (who (:p "Type something in and press enter. New content is added at the top.")))
input
chat-pane)))
Related Content:











If that is the best example they can put together, I have no fear of needing to learn LISP.
oh please no, why do we make easy things difficult.
Using CLOS looks like the kiss of death. I’ve seen a couple big programs that got refactored to use CLOS, but I’ve never seen a small program use CLOS and survive. CLOS is just too unwieldy at that stage — if you want a big industrial-strength object system, at the cost of making your program harder to work with, we’ve got plenty of other languages like that already.
This is Lisp syntax, but without using any of the features that make Lisp awesome.
cool .. some feedback :)
..i’m not forcing the user to use clos; the widgets use them, but other than that it’s just plain lisp — whatever the user wants to use..
ok, so how would you guys express something like this, ideally, using “lisp syntax”?
..i’d _really_ like to know .. email me if you cba. posting here: larsnostdal@gmail.com
..oh, or post it on the forum even:
http://groups.google.com/group/symbolicweb
..but again; i’m really not forcing the user to use CLOS .. the INPUT and CHAT-PANE slots could just be a variables in a LET or whatever..
..callbacks are just regular lambdas; not CLOS methods etc…
..that chat thing could be constructed in real-time by playing in the REPL or temporary buffers also, of course.. ..that’s how i work with or construct programs in SW actually
..and i’d like to see how you (non-lispers, it seems) guys at the top of the comments here express something like this in your languages..
..keeping in mind that this is the entire chat program (meaning no need for extra client side code from the user) .. if you can do better (which i doubt actually) i’ll copy you or your framework’s style :)
Interesting idea to use Lisp!
Not sure it’ll take off, I’m sticking to StreamHub Ajax / Comet Server for now.
Lisp and the web…hmm.