Write a Blog >>
GPCE 2016
Mon 31 October - Tue 1 November 2016 Amsterdam, Netherlands
co-located with SPLASH 2016
Mon 31 Oct 2016 14:30 - 15:00 at Zürich 1 - Generative Programming II Chair(s): Ulrik Schultz

In today’s web applications asynchronous requests to remote services using callbacks or futures are omnipresent. The continuation of such a non-blocking task is represented as a callback function that will later be called with the result of the request. This style of programming where the remainder of a computation is captured in a continuation function is called continuation-passing style (CPS). This style of programming can quickly lead to a phenomenon called “callback hell”, which has a negative impact on the maintainability of applications that employ this style. Several alternatives to callbacks are therefore gaining traction within the web domain. For example, there are a number of frameworks that rely on automatically transforming code, written without callbacks in a direct sequential style, into the continuation-passing style. However, these frameworks often employ a conservative approach in which each function call is transformed into CPS. Even when they do a selective transformation they will often encapsulate the entire remainder of the computation in the continuation. This conservative approach can sequentialise requests that could otherwise be run in parallel. So-called delimited continuations can remedy, but require special marks that have to be manually inserted in the code for marking the beginning and end of the continuation. In this paper we propose an alternative strategy in which we apply a selective and delimited CPS transformation that operates on a Program Dependence Graph instead to find the limits of each continuation. We implement this strategy in JavaScript and demonstrate its applicability to various web programming scenarios.

Slides (gpce16.pdf)1.25MiB