SymbolicWeb: Ajax and Comet with Lisp
Date : 2008 06 25 Category : Tech & DevelopmentNo 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:
PLAIN TEXT LISP:;;;; 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)))