[plt-scheme] Continuations vs REST

From: Noel Welsh (noelwelsh at gmail.com)
Date: Thu Mar 26 08:49:32 EDT 2009

On Fri, Mar 20, 2009 at 6:16 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:

> That said, I don't really agree with your article.  I think it sets up
> a false dichotomy and thus undersells continuations.

The main point of the article was to show that traditional web dev.
techniques are still useful in predominantly continuation based apps.
It is basically a reaction to various comments I've read that suggest
people think you have to use one or the other. I agree with your main
point that continuations = REST from a theoretical perspective, but I
think there are some important practical issues which prevent this
equality from holding in all cases.

This first issue is one of space. Storing continuations on the client
is not a universal solution. You are limited to how much space you can
store on the client. A URL can be at most about 2000 characters, and a
cookie 4K. There are various proposed extension mechanisms (Google
Gears is one; I think the WhatWG has another) but they aren't common
place enough to use. So you can't serialise all continuations to the
client. The typical solution is to store a reference (e.g. a file
name) in the continuation, rather than the data itself, and I take it
this is what file boxes are for. So you can use continuations, but not
in a fully automatic way (i.e. you have to do some work to annotate
those parts of your program that shouldn't be stored in the

The second issue is restoring continuations across code changes. If I
change my code, even in a trivial way, it is likely none of the
serialized continuations can be restored. The solution here to define
some external interface to the program (e.g. params in URLs) and
program using that interface -- we're back at traditional REST here
(the dispatch library is good here). Now this is not really a big
issue. Dispatchers make it ridiculously easy to create good URLs.  If
you mix dispatchers and continuations and encounter a continuation you
can't restore you can normally make a good guess at the page the user
wants, and redirect them to it. Again, you can use continuations but
have to do some extra work.


Posted on the users mailing list.