Hi Andreas
I posted the code (URL way below) with the caveat that nothing about
it is finalized. Right now I'm interested in developing an
appropriate abstraction for server side development that allows
flexibility while still eliminating much of the burden of state
management from the developer. As much as possible I want the server-
side web app script to feel like writing a stand-alone app.
Another problem I'd like to solve is how to have sessions interact
and the possibility of having web apps spawn persistent threads that
can be accessed by other threads/sessions or re-accessed later.
For example, say I have a web app page that sends an email to someone
for a lost password. Rather than having the user wait for the lost
password to be sent, I would first check if a lost password sender
daemon is running within the web app container. If it is I'll send
it a message saying "add this email to the list of users to deal
with" or else I'd spawn the daemon and then send the thing out. The
webpage would then immediately report success with the daemon dealing
with sending out the lost password.
This is probably a silly example as the latency of sending an email
within a web app isn't that high. However in the past I've developed
web apps that relied on externally running programs to handle other
aspects of the app. I want to do away with this and allow all of it
to exist inside of one app.
I'm not happy with the current session model. Here are the good
things: Right now a new isolated sleep script is created per IP that
accesses the site. The isolated sleep script shares code and
environment (functions, operators, predicates) with other clients.
This sharing allows session initialization to happen really quickly.
Each session safely execute asynchronous to the other sessions even
though they share a lot of static data. End result - little work to
create each session and each session is thread safe compared to the
other sessions allowing it to be very fast.
The part I'm not happy with is the creation of sessions. The
webserver decides when sessions should be created and dishes them out
accordingly. I'd like to see a way to push more control for this
down to the actual web app.
I used this model for the creation of a one-off web app awhile back.
It worked well internally where I was able to assume no NAT and
entanglement of sessions. Having the server automatically issue a
cookie to track sessions is an option.
Anyways I did quite a bit of functional-style programming when I
developed that app and I found that this server gave me a lot of
things for free. For example I had this subroutine called
printTable. It would accept an array of "rows" to render, an array
of column names, a hash mapping column names to render functions, and
another hash mapping column names to comparison functions. Normally
in ASP.NET and friends one would have a DataGrid object and have to
create a subclass that populates all of this stuff. I was able to
get this kind of flexibility without having to create scaffolding code.
As for the free stuff: The persistent script environment/session
allowed me to persist the array rows between sessions. As the user
sorted it and refreshed the page their data view would still be
there. They could apply whatever transforms they wanted to the array
and it would keep operating on their working set.
This is a neat opportunity to retool the server side for the
adventurous. Paul Graham and Robert Morris wrote their own
continuation server for viaweb. Okcupid.com has their own server
written in Lisp. Sleep isn't Lisp but it has some powerful
constructs that we can use to break pop-culture assumptions about
what a server side app looks like and to make something that is a
pleasure to develop in.
I've posted the source code here:
http://mattress.dashnine.org/download/mattress042108.tgz
The main contribution inside is a usable version of NanoHTTPD. I
added HTTP cache to the server. Probably some other stuff as well.
No template engine (yet?). If you're interested in hacking on this
we could go about it the right way. I can load it up into an SVN and
start the template of a functional specification on a wiki. We can
nail down some of the project decisions through the functional spec
and once that is settled go forward with writing code.
http://www.joelonsoftware.com/articles/fog0000000036.html
http://www.joelonsoftware.com/articles/fog0000000035.html
http://www.joelonsoftware.com/articles/fog0000000034.html
-- Raphael
On Apr 21, 2008, at 5:43 PM, Andreas Ravnestad wrote:
> On 4/17/08, Raphael Mudge <rsmu...@gmail.com> wrote:
> [...]
>> The Sleep website has moved as well. It is now at http://
>> sleep.dashnine.org/.
>> I'm currently writing a continuation server called Mattress. Its an
>> integration between Sleep and a hacked NanoHTTPD. I'm hosting
>> about 6
>> sites on it now. I built something like Mattress a year ago for
>> a one
>> off web app and I was very happy about how Sleep helped my server
>> side
>> productivity. I'll plan to open it up if there is interest (or even
>> if there isn't).
> I'm very interested in that, are you using any kind of templating?
> -Andreas