[racket] Racket Web Server

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Dec 12 08:58:13 EST 2011

Another good thing to read about continuations is the continuation chapter


Here's my short take on "why" continuations for the Web:

* Due to HTTP's stateless nature, Web clients must "remind" Web servers of
what the server was doing for the client. In any context, "what was going
to happen" is the continuation of the computation.

* There are three ways to capture a continuation: incorrectly, correctly
(manually), and correctly (automatically).

-- Incorrectly is what most people due by assigning a "session" id that
makes it so each client can only be doing one thing and that thing is
stored on the server and referenced by an identifier held by the client.
This is incorrect because Web browsers can have many pages open, use the
Back button, etc AND because storing things on the server like this
increases resource usage.

-- Correctly (manually) is what most simple Web programs do. The programmer
breaks up each step of the computation into a different PHP file (or
function) and painstakingly records the environment of that step in hidden
form values, URL parameters, etc. This manual process is difficult,
error-prone, and frustrating, because it is so sensitive to the particular
computation and almost entirely administrative labor.

-- Correctly (automatically) is what the Racket Web server provides: you
write your application as if HTTP were stateful and it compiles (or runs)
it using the constraint of real HTTP. You never need to think about what is
left to do, what free identifiers there are, etc.

* Basically, continuations make Web programming like normal programming on
the console. You don't really need to know anything special. It's the
hardest for people who have used other Web frameworks because almost
everything they do is now unnecessary, so you keep thinking that you need a
way to make a "session" (or something) and you'll never see one.

That said, the Racket Web server does not force you to use these features.
You can "program Fortan in any language" and write a PHP program. You make
prefer Racket-PHP to normal PHP, but some things will be annoying, like
having to bake your own session management. I find that most Racket apps
use continuations directly in very few situations (multi-page forms) but
mainly use the ability to bind a closure to a link a lot (although this
features needs continuations inside its implementation). [This is the
difference between send/suspend and send/suspend/dispatch... roughly.]


On Mon, Dec 12, 2011 at 2:40 AM, Gerry Weaver <gerryw at compvia.com> wrote:

> Hi Neil,
> Thanks for the link. It was VERY helpful. It does answer the "why" part of
> the question, but not necessarily the "if" part. I'm thinking in terms of a
> real world application and it's maintainability. It seems while a
> particular problem was solved, the bar on the price of entry to the code
> was raised significantly. If the problem were to be solved in a way that
> would maintain a more conventional design, it would be accessible to a
> wider range of developers. There are many that struggle with understanding
> continuations (myself included). I was just trying to compare the benefits
> of a continuation based design versus a more conventional approach. At this
> point, I still think it would depend heavily on the specific use case and
> developer skill level. Don't get me wrong. It's very cool! However, if the
> goal were to make scheme based web development accessible to the masses, I
> don't think a
> continuation based design would be the right choice. I will continue to
> ponder this question as I become more proficient in the language. I think
> it is important to capture these kinds things when learning any new
> language. It's a moment that will never come again. It seems I will
> inevitably reach a point where I am no longer able to evaluate things like
> this objectively.
> Thanks,
> Gerry
> -----Original Message-----
> > From: "Neil Van Dyke" <neil at neilvandyke.org>
> > To: "Gerry Weaver" <gerryw at compvia.com>
> > Cc: users at racket-lang.org
> > Date: 12/12/11 02:41
> > Subject: Re: [racket] Racket Web Server
> >
> > Gerry Weaver wrote at 12/12/2011 02:29 AM:
> > > What exactly are the benefits of a continuation based design?
> >
> > Does this paper address your questions?
> >
> > Krishnamurthi, Hopkins, McCarthy, Graunke, Pettyjohn, Felleisen,
> > "Implementation and Use of the PLT Scheme Web Server",
> > Journal of Higher-Order and Symbolic Computing
> > http://www.ccs.neu.edu/racket/pubs/#hosc-07
> > http://www.ccs.neu.edu/racket/pubs/hosc07-sk-mf.pdf
> >
> > --
> > http://www.neilvandyke.org/
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111212/27e81529/attachment.html>

Posted on the users mailing list.