
Is this how news.ycombinator.com runs? (Ctrl+F for "Closures Simulate Subroutines") - MobileDigit
http://lib.store.yahoo.net/lib/paulgraham/bbnexcerpts.txt
======
nostrademons
I always assumed it was, and that the closures are stored in the user's
session (in memory, on the server). You notice that if you leave a comment
reply box up on the screen long enough, you'll get "Unknown or expired
session" when you try to submit, and have to back up to the main comment page
before you can try again?

~~~
pg
For calls that don't need to know about more state than their arguments, we
just use an ordinary url with arguments. Otherwise we make a closure and store
it in a hash table in memory, and make the url be x?fnid= where the argument
is the hash key. When an http request comes in, we call the corresponding
closure. Sometimes what to do next after following a link generated by the
closure (e.g. what to do after logging in when you're not logged in and you
submit a link through the bookmarklet) is part of the state of the closure; in
that case it's a bit like a continuation.

We keep only the most recently generated 20,000 closures. When you click on a
link that says it has expired, that means either it has been purged from the
closure table, or that we've restarted the server.

~~~
malkia
Isn't there a risk, that someone can (accidentally or not) enter hash-code of
someone else's "closure"?

~~~
mdakin
One could avoid that problem by keeping track of the owner of each closure and
ensuring the user is properly authenticated before calling the closure.

------
nickb
Paul, could you enlighten us how well does this type of development (Lisp
macro/closure based) integrate with JS and Ajax? I'm interested in
asynchronicity of the Ajax... Ruby and Python with Protoype and Scriptaculous
make this very easy indeed...

~~~
pg
How much Ajax do you see on this site? (The answer is that I don't know,
because I haven't tried.)

