Phil Windley's Technometria blog has an interesting application of state management via continuations. Unfortunately he uses a strawman "Web application" to demonstrate how to solve a problem that doesn't actually exist.
Supposed I asked you to build a program to grab the current exchange rates from the Federal Reserve Bank in New York (FRBNY) in XML, prompt the user for the currency to exchange dollars for, then prompt the user for the dollars to convert, and then display the result. You might write a program that looks like this:
- get the rates from the Federal Reserve Bank
- show the first prompt and record the currency choice
- show the second prompt and record the dollar amount
- query the XML to extract the right information using the user input
- calculate the result and display it
Now, suppose I asked you to convert your program to a Web application. Still a five minute job? Hardy, and the increase in time is more than just the problem of building the Web pages. What you’d probably do is put each of those steps into a separate script and then bind them all together with a little state machine in the CGI program that jumped to the right script based on state variables that you encoded in the URL, a hidden field, or a cookie. Sadly, it wouldn’t end up looking anything like the program that you’d write if you were just grabbing the input from a terminal.
To be honest, if asked to build that program, I wouldn't do it in that sequence (don't block on retrieving a remote resource 'just in case' you might need it) and I'd gather all user input in one shot. Sure, command line consoles are broken in that regard but Web applications are not. The problem I have is the "you'd probably put each of those steps into a separate script..." part. First, it's a horrible user experience splitting things up that way and secondly you only need a single resource to represent the conversion of a currency value. Build your application around a decent resource model and this 'problem' evaporates.
There isn't a problem with Web applications that need continuations - although they are an interesting way to manage state - but there is a problem with they way people build Web applications with older tools. And articles presenting a poor example as if it were 'best practices' or 'everybody does it this way' don't help.