skip to main content
10.1145/2993236.2993243acmconferencesArticle/Chapter ViewAbstractPublication PagesgpceConference Proceedingsconference-collections
research-article

Dependence-driven delimited CPS transformation for JavaScript

Published:20 October 2016Publication History

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.

References

  1. Andrew W. Appel. Compiling with Continuations. Cambridge University Press, New York, NY, USA, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. Olivier Danvy and John Hatcliff. CPS-transformation After Strictness Analysis. ACM Lett. Program. Lang. Syst., 1(3):195–212, September 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Alex Davies. Async in Csharp 5.0 - Unleash the Power of Async. O’Reilly, 2012.Google ScholarGoogle Scholar
  5. Continuation.js documentation. Continuation.js. https:// github.com/BYVoid/continuation, 2013.Google ScholarGoogle Scholar
  6. Streamline documentation. Streamline.js. https://github. com/Sage/streamlinejs, 2015.Google ScholarGoogle Scholar
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle Scholar
  10. Rich Hickey and contributors. core.async clojure library. https://github.com/clojure/core.async, 2013.Google ScholarGoogle Scholar
  11. Robert Hieb, R.Kent Dybvig, and III Anderson, ClaudeW. Subcontinuations. LISP and Symbolic Computation, 7(1):83– 109, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. Jens Krinke. Program slicing. In S K Chang, editor, Handbook of Software Engineering and Knowledge Engineering 3. World Scientific Publishing, 2004.Google ScholarGoogle Scholar
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. Oni Labs. Stratified javascript. http://onilabs.com/ stratifiedjs, 2012.Google ScholarGoogle Scholar
  19. Jens Nicolay, Carlos Noguera, Coen De Roover, and Wolfgang De Meuter. Determining Coupling In JavaScript Using Object Type Inference. In SCAM13, 2013.Google ScholarGoogle ScholarCross RefCross Ref
  20. 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 ScholarGoogle Scholar
  21. Scala programming documentation. Scala package: continuations. http://www.scala-lang.org/api/2.10. 1/index.html#scala.util.continuations.package, 2016.Google ScholarGoogle Scholar
  22. Ryan Seddon. Introduction to javascript source maps. http://www.html5rocks.com/en/tutorials/ developertools/sourcemaps/, 2012.Google ScholarGoogle Scholar
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. Frank Tip. A Survey of Program Slicing Techniques. Technical report, Amsterdam, The Netherlands, The Netherlands, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. Mark Weiser. Program slicing. IEEE Trans. Software Eng., 10(4):352–357, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Dependence-driven delimited CPS transformation for JavaScript

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      GPCE 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences
      October 2016
      212 pages
      ISBN:9781450344463
      DOI:10.1145/2993236

      Copyright © 2016 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 20 October 2016

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate56of180submissions,31%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader