skip to main content
research-article

Directing JavaScript with arrows

Published:26 October 2009Publication History
Skip Abstract Section

Abstract

JavaScript programmers make extensive use of event-driven programming to help build responsive web applications. However, standard approaches to sequencing events are messy, and often lead to code that is difficult to understand and maintain. We have found that arrows, a generalization of monads, are an elegant solution to this problem. Arrows allow us to easily write asynchronous programs in small, modular units of code, and flexibly compose them in many different ways, while nicely abstracting the details of asynchronous program composition. In this paper, we present Arrowlets, a new JavaScript library that offers arrows to the everyday JavaScript programmer. We show how to use Arrowlets to construct a variety of state machines, including state machines that branch and loop. We also demonstrate how Arrowlets separate computation from composition with examples such as a drag-and-drop handler and a bubblesort animation.

References

  1. Atul Adya, Jon Howell, Marvin Theimer, William J. Bolosky, and John R. Douceur. Cooperative task management without manual stack management. In ATEC '02: Proceedings of the General Track of the annual conference on USENIX Annual Technical Conference, pages 289--302, Berkeley, CA, USA, 2002. USENIX Association. ISBN 1-880446-00-6. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. W. Appel. Compiling with continuations. Cambridge University Press New York, NY, USA, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Magnus Carlsson and Thomas Hallgren. Fudgets: a graphical user interface in a lazy functional language. In FPCA '93: Proceedings of the conference on Functional programming languages and computer architecture, pages 321--330, New York, NY, USA, 1993. ACM. ISBN 0-89791-595-X. doi: http://doi.acm.org/10.1145/165180.165228. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Antony Courtney and Conal Elliott. Genuinely functional user interfaces. In Proceedings of the 2001 Haskell Workshop, pages 41--69, 2001.Google ScholarGoogle Scholar
  5. Douglas Crockford. JavaScript: The Good Parts. O'Reilly Media, Inc., 2008. ISBN 0596517742. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. David Flanagan. JavaScript: The Definitive Guide. O'Reilly Media, Inc., 2006. ISBN 0596101996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Paul Hudak, Antony Courtney, Henrik Nilsson, and John Peterson. Arrows, robots, and functional reactive programming. In Advanced Functional Programming, 4th International School, volume 2638 of LNCS, pages 159--187. Springer-Verlag, 2003.Google ScholarGoogle Scholar
  8. John Hughes. Generalising monads to arrows. Science of Computer Programming, 37:67--111, May 2000. URL http://www.cs.chalmers.se/~rjmh/Papers/arrows.ps. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Hugh C. Lauer and Roger M. Needham. On the duality of operating systems structures. In Proceedings of the 2nd International Symposium on Operating Systems, October 1978.Google ScholarGoogle Scholar
  10. Peng Li and Steve Zdancewic. Combining events and threads for scalable network services implementation and evaluation of monadic, application-level concurrency primitives. In PLDI '07: Proceedings of the 2007 ACM SIGPLAN conference on Programming language design and implementation, pages 189--199, New York, NY, USA, 2007. ACM. ISBN 978-1-59593-633-2. doi: http://doi.acm.org/10.1145/1250734.1250756. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Leo Meyerovich, Arjun Guha, Jacob Baskin, Greg Cooper, Michael Greenberg, Aleks Bromfield, and Shriram Krishnamurthi. Flapjax: A Programming Language for Ajax Applications. In OOPSLA '09: Proceedings of the 24th ACM SIGPLAN Conference on Object-Oriented Programming Systems Languages and Applications, New York, NY, USA, 2009. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Rob von Behren, Jeremy Condit, Feng Zhou, George C. Necula, and Eric Brewer. Capriccio: scalable threads for internet services. In SOSP '03: Proceedings of the nineteenth ACM symposium on Operating systems principles, pages 268--281, New York, NY, USA, 2003. ACM. ISBN 1-58113-757-5. doi: http://doi.acm.org/10.1145/945445.945471. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Philip Wadler. The essence of functional programming. In POPL '92: Proceedings of the 19th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 1--14, New York, NY, USA, 1992. ACM. ISBN 0-89791-453-8. doi: http://doi.acm.org/10.1145/143165.143169. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Zhanyong Wan and Paul Hudak. Functional reactive programming from first principles. In PLDI '00: Proceedings of the ACM SIGPLAN 2000 conference on Programming language design and implementation, pages 242--252, New York, NY, USA, 2000. ACM. ISBN 1-58113-199-2. doi: http://doi.acm.org/10.1145/349299.349331. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Directing JavaScript with arrows

      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

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 44, Issue 12
        DLS '09
        December 2009
        107 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1837513
        Issue’s Table of Contents
        • cover image ACM Conferences
          DLS '09: Proceedings of the 5th symposium on Dynamic languages
          October 2009
          118 pages
          ISBN:9781605587691
          DOI:10.1145/1640134
          • Program Chair:
          • James Noble

        Copyright © 2009 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 26 October 2009

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!