Posted by Daniel Lyons
Thu, 21 Dec 2006 15:11:01 GMT
Ugly Woman #1 “Lisp” is making good progress. I haven’t dealt with vtemplate parsing yet or figured out how to do anything with Portable AllegroServe, which seems to be the de facto Lisp web serving framework, but I do have this working:
(defsite "clanspum.net")
(defregion "clanspum.net" "content" () "/index.html"
"This is the content.")
I’m pretty happy with that doing the right thing. There’s a lot of crap behind it already (~125 lines) which seems like a lot, and is a lot, especially considering how much of it is OO crap. I would have liked to have skipped the OO business but couldn’t manage to make this code work without it for abstraction purposes. I’m sure it would have been a different story in Haskell or Erlang though.
Tags lisp, voltaire | no comments
Posted by Daniel Lyons
Wed, 13 Dec 2006 07:43:44 GMT
So often lately I think about how to make Voltaire functional. A key part of Voltaire is adding code for specific sites, both via plugins and into the regions themselves. This immediately disqualifies OCaml.
The problem of putting code into a template is basically a parsing problem. I already have parsers for VTemplates in OCaml and Haskell. It was a snap. I know of no parsing helper tools for Lisp. Bummer. Erlang has yecc and leex, which I might be learning soon, even though they’re very unorthodox.
OTOH, putting Lisp code into a region and running it later is a snap. eval is part of the REPL, after all. So it takes to dynamically inserted code like a dream. Erlang has a built-in library for evaluating strings, but it’s somewhat less convenient to use than Lisp’s eval. But it’s probably better too, it being Erlang. Haskell, I thought, has no eval. Actually it does, in the form of a library that doesn’t compile against GHC 6.6 (industry standard). It’s sort of wacky to me that you can implement eval as a library, but whatever.
I have in mind a good reason to use Lisp though: keeping data and functions together in the image. After all, the whole “regions table” could be kept in memory as a sort of infinitely nested hash or a-list, carrying around templates which have been compiled into simple functions which are applied to the request args or the requested path or whatever. In fact, it seems clever enough it would be fun to use. One drawback to such an implementation is that the code must then be kept in memory, rather than in a database (I think). So, I would have to supply a mechanism for changing the templates over the wire, and I’d have to keep around the template source, and worry about reading and writing this data structure to disk. Michael’s site is larger than Nina’s somehow and comes to a little under one meg of actual region data, though, so it may not be so bad performance-wise. But code would have to exist which currently doesn’t. On the plus side, if it were simply a nested a-list, the REPL could take care of the disk access, mostly. A hash table would be more trouble.
So, I have bits and pieces of Voltaire implemented in a half-dozen or so languages (several other chunks I haven’t mentioned here). As a family, I’d like to call them The Old Women, after the half-assed woman of Candide. If I eventually distill an implementation in one of them, I may name it Pangloss, since that name befits anything the result of such foolish optimism as I have.
...
I was told earlier today that my functional programming chops, combined with another person’s OO chops, “and Eastern Europe doesn’t stand a chance!” Rock on.
Tags erlang, functional, haskell, lisp, programming, voltaire | no comments