3 ms·
I saw a demo of Seaside a few years ago where they were using continuations to write code like while( updateBillingInfo() != 'done' ){ displayUpdateB
by johnwatson11218 16y ago
I saw a demo of Seaside a few years ago where they were using continuations to write code like
while( updateBillingInfo() != 'done' ){
displayUpdateBillingInfo();
}
renderCheckoutScreen();
....
The point was that a method call that might present output to a user or read in a value could be an entire http render/response cycle. The 'updateBillingInfo()' method above could include arbitrary web interaction with the user. What was allowing all this was the fact that the framework was using continuations. So that when the user was finished updating the billing info the stack of the above code could be revived and resumed.
I thought it was so cool to be able to structure complex web interaction with that kind of procedural code. The closest thing I've seen at work is srping webflow but that is nowhere near as cool.
For years we have been able to inject a password prompt to a user when they request a secured resource. After the user logs in they can go to the secured page. What about something like a multipage color chooser? so that at any point in a web interaction the user can go into the color chooser sequence of screens and have the end result returned to wherever they were when it kicked off? And being able to stack these re-usable flows arbitrarily deep?
What I have seen in production is some kind of hack like a 'returnTo' http parameter that lets the other flow know where to send the user when they finish that part of the interaction. In some cases you see people attempt 2 levels by passing the parent and grandparent as a string or something like that.
The thing is that there is no way I would dive into smalltalk to get features like this. For better or worse I am tied to Java on the server side.
- amock 16y agoWhy are you tied to Java? Is there something about Smalltalk that makes you not want to learn it or are there other constraints?
- johnwatson11218 16y agoWell it is the main language that I have worked in for many years now. I did some Perl early on and have done small one off projects in Python and Ruby. I really like how rock solid the jvm is and then there is always Scala and Groovy (mostly Groovy). Another thing is that in my personal programming the server side isn't really where I hurt the most. Currently I'm more interested in client side stuff. I am learning Flex and ActionScript at the moment in order to convert some code I did in javascript/ajax to Flex.
- mgkimsal 16y agoHave you looked at webflows in Grails? I believe it's using spring's webflow stuff, but is more grails/groovy-oriented, which might be easier to deal with.
- whakojacko 16y agohave you looked into lift? It takes quite a few features from seaside, among others. And scala is much better to work with than java...
- sandGorgon 16y agoRecently a team won the DevDerby (" were challenged to create as usable and fully functional a program as possible in only six hours") http://www.lmcalpin.com/post/1109835129/dev-derby-2010 http://www.lmcalpin.com/post/1109835129/dev-derby-2010 They did it using the Play Framework in pure Java. Incidentally the Play framework supports Scala, but this example goes on to show that Java is'nt quite out of the game yet.
- lolipop1 16y agoAt the end of the day, how do you implement scalable multi-threaded continuations? Yes the code has a better allure, but it's not exactly hard to add parameters to http requests. Having used a few frameworks, I can tell you it's also easier to debug code that's closer to http requests. Being able to simply look at what's being passed in a simple way and understand everything instantaneously is a big advantage. Actually, this argument is more about the tools at hand, but there are definitively more and better tools to analyze http requests than anything else.
- johnwatson11218 16y agoyea I hear you. The problem I have will passing the http parameters is that it only goes one level deep. If you want to nest it arbitrarily you would have to build up a comma separated list of values to refer to all the places you need to return to. At that point, if you think of this list of return places as a set of pointers it is as if you are implementing a stack. Having this kind of thing as a first class construct could maybe allow this to be checked by the compiler. To be honest the details of implementing 'scalable multi-threaded continuations' is beyond my skill level.
- draegtun 16y agoYes scaling continuations based web apps can be a big headache. I think this is why the Seaside developers have been scaling back continuations and making them optional in the framework: http://lists.squeakfoundation.org/pipermail/seaside/2007-December/015565.html http://lists.squeakfoundation.org/pipermail/seaside/2007-Dec... Coroutines are an interesting lighter alternative (though will still suffer from threading & session affinity issues). See coro based libraries/frameworks influenced by Seaside like Continuity (http://continuity.tlt42.org/ http://continuity.tlt42.org/) & Nagare (http://www.nagare.org/ http://www.nagare.org/) (which I think uses coros?). Here is a fulling working Continuity example: use strict; use warnings; use Continuity; use HTML::AsSubs; Continuity->new->loop; sub main { my $r = shift; ########################################### # helpers my $update_billing_info = sub { return 1 if eval { $r->param('updated') }; return; }; my $display_update_billing_info = sub { $r->print( form( input( {type => 'checkbox', name => 'updated'}, 'updated?' ), br, input( {type => 'submit'} ), p( "No. of tries thus far - $_[0]" ), )->as_HTML ); }; my $render_checkout_screen = sub {$r->print("Updated after $_[0] submits!")}; ########################################### # business logic my $count_tries; while (not $update_billing_info->()) { $display_update_billing_info->( $count_tries++ ); $r->next; } $render_checkout_screen->( $count_tries ); }
- harryh 16y agoYou should look into Lift (http://liftweb.net http://liftweb.net). It has a lot of what you describe. Here's a getting started slide deck I gave last year: https://docs.google.com/present/view?id=dcbpz3ck_24f3v83ggz&revision=_latest&start=0&theme=blank&cwj=true https://docs.google.com/present/view?id=dcbpz3ck_24f3v83ggz&...