20

The question is: why aren't continuations (in Ruby) and coroutines (in Python) more widely used for Web programming?

Server-side web programming is made difficult by the problem of preserving state between requests. Two elegant, and related, solutions to this are continuations (as found in Scheme, Ruby and Smalltalk) and coroutines (as found in Python and Go).

Bruce Tate in his Beyond Java (O'Reilly, 2005) talked about Ruby on Rails and Seaside as exciting new developments in Web programming. To me, Seaside was the real breakthrough: using Smalltalk continuations, Seaside made it very easy to program complex request/response sequences.

I know about Python coroutines being used in Tornado and Twisted to reduce callbacks, but that is somewhat low-level, compared to writing a view/controller in a single coroutine to handle a sequence of HTTP requests to complete an online purchase, for example.

I wonder why these ideas that look so good on paper are not more widely deployed in Python and Ruby. Is it just a cultural matter? Limitations in the facilities as implemented in these languages? Or is there a fundamental flaw in these approaches in the context of Web development?

Luciano Ramalho
  • 1,981
  • 18
  • 22
  • 1
    If you're smart enough, why not go with it? – mlvljr Aug 28 '12 at 22:48
  • 7
    mlvljr: I'm pretty sure people smarter than I have tried and I'd like to hear from them before trying it myself. – Luciano Ramalho Aug 28 '12 at 22:57
  • 3
    I fear this question falls afoul of [the FAQ's "Don't Ask"](http://stackoverflow.com/faq#dontask) clause. You have multiple questions, and each could be quite a long discussion. – the Tin Man Aug 28 '12 at 23:42

3 Answers3

5

I've used Seaside and continuations are a beautiful model for developing client server webapps. They simplify traditional client/server applications that I couldn't believe why no other langugage was doing it.

But unfortunately webapps aren't what they used to be. Instead of the requesting only one page, now with ajax there are multiple requests at different times. That is why continuations aren't as useful as they used to be.

Even Avi Bryant (original author of Seaside) has said that under ajax making callbacks easier (event driven programming) is more important than continuations.

Take a look at this quora discussion for more: http://www.quora.com/Whats-the-best-continuation-based-web-framework

elviejo79
  • 4,592
  • 2
  • 32
  • 35
  • 2
    elviejo: thanks for your insight and for the link to the Quora answer which is really good. – Luciano Ramalho Aug 29 '12 at 12:48
  • 2
    This is a very good point. I would say continuations are much better suited at API calls that might need to be made in succession. – rbp Aug 29 '12 at 20:33
1

You application should be written on continuation/coroutines framework, as well as support libraries too. It's not trivial model to understand by beginners. Also there are much easier frameworks like gevent, which provides the same possibilities in making green threads, and easier to use because of monkey patching.

Alex
  • 1,210
  • 8
  • 15
1

Mainly because of non-technical reasons. The number of people knowing Seaside or even Smalltalk is small, so there is no large pool of cheap programmers that can be hired. Because of this the number of service providers knowing how to install and maintain a Seaside system is also low.

Stephan Eggermont
  • 15,847
  • 1
  • 38
  • 65