Please let me go to bed, Sleep 2.1-b22 released

4 views
Skip to first unread message

Raphael Mudge

unread,
Apr 17, 2008, 3:03:28 AM4/17/08
to Sleep Developers
Hello everyone,
I don't know if it is long awaited or not but Sleep 2.1-b22 has been
released. In this release I make good on a promised feature to
someone: http://sleep.dashnine.org/sleeplang.html#marty

What's new?

- Expanded the role of ordered hashes. They now allow the
specification of a miss and removal policy closures. The miss policy
closure provides a default value for a key when no value exists in the
ordered hash. The removal policy closure determines whether or not to
remove the last value in the hash (based on the order). There are
some neat possibilities here. Check out my Fibonacci number
generator:

sub fib
{
local('%fhash');
%fhash = ohash(0 => 0, 1 => 1);
setMissPolicy(%fhash,
{
return $1[$2 - 1] + $1[$2 - 2];
});
return %fhash[$1];
}

- Updated the profiler to negate the execution time of child functions
when calculating runtime of a function. This provides much more
accurate (and useful) information about where your program is spending
its time.

- Fixed some of Sleep's internals to follow new conventions that I
haven't documented yet (some of them I made up today).

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).

So thats it. Sleep 2.1-b22, go download it. I would like to release
Sleep 2.1 this summer. Maybe I'll do the major release on July 20.
Oh yes, one more thing, Sleep had another birthday a few weeks ago.
It is now 6 years old.
Happy birthday Sleep.

http://sleep.dashnine.org/ new
server, old homepage
http://sleep.dashnine.org/changelog.html see what I broke
http://sleep.dashnine.org/download.html get it

-- Raphael

Poarman

unread,
Apr 18, 2008, 5:27:05 PM4/18/08
to Sleep Developers
Hi Raph,

You are totally awesome. Working on prepared statements and
serializing to Oracle. Having problems. That is the last part of my
memory management problem. BTW, I uploaded part of my project
directory as a template for new people. Maybe some people will find
it useful. Questions or comments welcome.

later,
poarman
> The Sleep website has moved as well.  It is now athttp://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).
>
> So thats it.  Sleep 2.1-b22, go download it.  I would like to release
> Sleep 2.1 this summer.  Maybe I'll do the major release on July 20.
> Oh yes, one more thing, Sleep had another birthday a few weeks ago.
> It is now 6 years old.
> Happy birthday Sleep.
>
> http://sleep.dashnine.org/                                  new
> server, old homepagehttp://sleep.dashnine.org/changelog.html            see what I brokehttp://sleep.dashnine.org/download.html             get it
>
> -- Raphael

Andreas Ravnestad

unread,
Apr 21, 2008, 5:43:56 PM4/21/08
to sleep-de...@googlegroups.com
On 4/17/08, Raphael Mudge <rsm...@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

Raphael Mudge

unread,
Apr 21, 2008, 7:50:49 PM4/21/08
to sleep-de...@googlegroups.com
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

Reply all
Reply to author
Forward
0 new messages