Dependence-Driven Delimited CPS Transformation for JavaScript
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 |
Mon 31 OctDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
13:30 - 15:10 | Generative Programming IIGPCE at Zürich 1 Chair(s): Ulrik Pagh Schultz University of Southern Denmark | ||
13:30 30mTalk | Actor Profiling in Virtual Execution Environments GPCE Andrea Rosà Università della Svizzera italiana, Lydia Y. Chen IBM Research Lab Zurich, Walter Binder University of Lugano | ||
14:00 30mTalk | Bootstrapping Domain-Specific Meta-Languages in Language Workbenches GPCE Gabriël Konat Delft University of Technology, Sebastian Erdweg Delft University of Technology, Netherlands, Eelco Visser Delft University of Technology, Netherlands Link to publication DOI Pre-print Media Attached | ||
14:30 30mTalk | Dependence-Driven Delimited CPS Transformation for JavaScript GPCE Laure Philips Software Languages Lab, Joeri De Koster Vrije Universiteit Brussel, Belgium, Wolfgang De Meuter Vrije Universiteit Brussel, Belgium, Coen De Roover Vrije Universiteit Brussel, Belgium File Attached |