Abstract
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 “call- back hell”, which has a negative impact on the maintain- ability of applications that employ this style. Several alter- natives to callbacks are therefore gaining traction within the web domain. For example, there are a number of frameworks that rely on automatically transforming sequential style code into the continuation-passing style. However, these frame- works often employ a conservative approach in which each function call is transformed into CPS. 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 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.
- Andrew W. Appel. Compiling with Continuations. Cambridge University Press, New York, NY, USA, 1992. Google Scholar
Digital Library
- Patrick Cousot and Radhia Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Proceedings of the 4th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 238–252. ACM, 1977. Google Scholar
Digital Library
- Olivier Danvy and John Hatcliff. CPS-transformation After Strictness Analysis. ACM Lett. Program. Lang. Syst., 1(3):195–212, September 1992. Google Scholar
Digital Library
- Alex Davies. Async in Csharp 5.0 - Unleash the Power of Async. O’Reilly, 2012.Google Scholar
- Continuation.js documentation. Continuation.js. https:// github.com/BYVoid/continuation, 2013.Google Scholar
- Streamline documentation. Streamline.js. https://github. com/Sage/streamlinejs, 2015.Google Scholar
- Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. The Essence of Compiling with Continuations. In Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation, PLDI ’93, pages 237–247, New York, NY, USA, 1993. ACM. Google Scholar
Digital Library
- Matthew Flatt, Gang Yu, Robert Bruce Findler, and Matthias Felleisen. Adding Delimited and Composable Control to a Production Programming Environment. SIGPLAN Not., 42(9):165–176, October 2007. Google Scholar
Digital Library
- Keheliya Gallaba, Ali Mesbah, and Ivan Beschastnikh. Don’t Call Us, We’ll Call You: Characterizing Callbacks in JavaScript. In 2015 ACM/IEEE International Symposium on Empirical Software Engineering and Measurement, ESEM 2015, Beijing, China, October 22-23, 2015, pages 247–256, 2015.Google Scholar
- Rich Hickey and contributors. core.async clojure library. https://github.com/clojure/core.async, 2013.Google Scholar
- Robert Hieb, R.Kent Dybvig, and III Anderson, ClaudeW. Subcontinuations. LISP and Symbolic Computation, 7(1):83– 109, 1994. Google Scholar
Digital Library
- Simon Holm Jensen, Anders Møller, and Peter Thiemann. Type analysis for JavaScript. In Proc. 16th International Static Analysis Symposium (SAS), volume 5673 of LNCS. Springer-Verlag, August 2009. Google Scholar
Digital Library
- Yukiyoshi Kameyama and Masahito Hasegawa. A Sound and Complete Axiomatization of Delimited Continuations. In In Proc. of 8th ACM SIGPLAN Int. Conf. on Functional Programming, ICFP’03, pages 177–188. ACM Press, 2003. Google Scholar
Digital Library
- Grzegorz Kossakowski, Nada Amin, Tiark Rompf, and Martin Odersky. Javascript as an Embedded DSL. In James Noble, editor, ECOOP 2012, volume 7313 of Lecture Notes in Computer Science, pages 409–434. Springer Berlin Heidelberg, 2012. Google Scholar
Digital Library
- Jens Krinke. Program slicing. In S K Chang, editor, Handbook of Software Engineering and Knowledge Engineering 3. World Scientific Publishing, 2004.Google Scholar
- Shriram Krishnamurthi, Peter Walton Hopkins, Jay A. Mc-Carthy, Paul T. Graunke, Greg Pettyjohn, and Matthias Felleisen. Implementation and use of the PLT scheme Web server. Higher-Order and Symbolic Computation, 20(4):431– 460, 2007. Google Scholar
Digital Library
- D. J. Kuck, R. H. Kuhn, D. A. Padua, B. Leasure, and M. Wolfe. Dependence Graphs and Compiler Optimizations. In Proceedings of the 8th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’81, pages 207–218, New York, NY, USA, 1981. ACM. Google Scholar
Digital Library
- Oni Labs. Stratified javascript. http://onilabs.com/ stratifiedjs, 2012.Google Scholar
- Jens Nicolay, Carlos Noguera, Coen De Roover, and Wolfgang De Meuter. Determining Coupling In JavaScript Using Object Type Inference. In SCAM13, 2013.Google Scholar
Cross Ref
- Jens Nicolay, Carlos Noguera, Coen De Roover, and Wolfgang De Meuter. Detecting Function Purity in JavaScript. In Proceedings of the 15th International Working Conference on Source Code Analysis and Manipulation (SCAM15), 2015.Google Scholar
- Scala programming documentation. Scala package: continuations. http://www.scala-lang.org/api/2.10. 1/index.html#scala.util.continuations.package, 2016.Google Scholar
- Ryan Seddon. Introduction to javascript source maps. http://www.html5rocks.com/en/tutorials/ developertools/sourcemaps/, 2012.Google Scholar
- Maciej Swiech and Peter Dinda. Making JavaScript better by making it even slower. In Modeling, Analysis & Simulation of Computer and Telecommunication Systems (MASCOTS), 2013 IEEE 21st International Symposium on, pages 70–79. IEEE, 2013. Google Scholar
Digital Library
- Frank Tip. A Survey of Program Slicing Techniques. Technical report, Amsterdam, The Netherlands, The Netherlands, 1994. Google Scholar
Digital Library
- Andrew Tolmach. Debugging Standard ML without Reverse Engineering. In In Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, pages 1–12. ACM Press, 1990. Google Scholar
Digital Library
- Mark Weiser. Program slicing. IEEE Trans. Software Eng., 10(4):352–357, 1984. Google Scholar
Digital Library
Index Terms
Dependence-driven delimited CPS transformation for JavaScript
Recommendations
Dependence-driven delimited CPS transformation for JavaScript
GPCE 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesIn 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 ...
A First-Order One-Pass CPS Transformation
FoSSaCS '02: Proceedings of the 5th International Conference on Foundations of Software Science and Computation StructuresWe present a new transformation of call-by-value lambda-terms into continuation-passing style (CPS). This transformation operates in one pass and is both compositional and first-order. Because it operates in one pass, it directly yields compact CPS ...
CPS transformation of beta-redexes
The extra compaction of the most compacting CPS transformation in existence, which is due to Sabry and Felleisen, is generally attributed to (1) making continuations occur first in CPS terms and (2) classifying more redexes as administrative. We show ...







Comments