[parenscript-devel] best practice for developing a JS-only HTML5 webapp?

Vladimir Sedach vsedach at gmail.com
Tue Jan 11 06:29:52 UTC 2011

> I wanted a setup where I could edit a Parenscript file, hit save, then
> hit refresh in my browser and immediately see the new code, just as if
> I were working in Javascript. I built a little server using
> Hunchentoot and cl-who that runs ps-compile-file on my parenscript
> source file as needed. This works fairly well, but maybe is not the
> best way to accomplish this.

I think the simplest way to accomplish this is using something like this script:

(defvar last-modified-time 0)

   (sleep 0.1)
   (with-open-file (in "/home/viper/file.paren" :direction :input)
     (when (< last-modified-time (file-write-date in))
       (with-open-file (out "/home/viper/file.js" :direction :output
:if-exists :supersede :if-does-not-exist :create)
         (princ (ps:ps-compile-stream in) out)
         (setf last-modified-time (file-write-date in))))))

It would be nice to polish up slime-proxy; there you won't even have
to hit refresh in the browser for the changes to take effect (what
Kelly McDonald is talking about). I think Daniel was the first to
suggest a "SLIME for Parenscript" project to me a couple of years ago,
but until slime-proxy came along no one had done much work on that. It
would be really nice to have things like autocompletion and other
SLIME features in an Emacs REPL that hooks up to the browser.

> However, there's a problem; I wanted to use parenscript functions
> without the namespace, so I defined a package in serve.lisp that uses
> parenscript, then put (in-package :innkeeper) at the top of my
> parenscript file. This doesn't work properly in the 2.2 release of
> Parenscript (which is what Quicklisp provides). It _does_ work in the
> git repo version (as of commit
> 0e01e555f404a7dcb8befb7587288c38abf526c2), but it's annoying to not be
> able to use Quicklisp for everything.

I think I know where this got fixed, but I'm not sure. I'll double
check that the unit test for that got added, and then make a new
release and ask Zach to add it to Quicklisp.

> Once I have a release version I'll want to come up with some lisp
> program that compiles the parenscript to javascript, minifies it, and
> sticks it in an also-minified html file from cl-who, so the whole
> thing is compiled down to a single file. I'd appreciate any
> best-practice tips on that too.

If you use ps:obfuscate-package and set *PS-PRINT-PRETTY* to nil, that
does almost as good a job as most minifiers. I should mention that in
the reference manual.

Hope that helps,

More information about the parenscript-devel mailing list