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.
- 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 Scholar
Digital Library
- A. W. Appel. Compiling with continuations. Cambridge University Press New York, NY, USA, 1992. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Antony Courtney and Conal Elliott. Genuinely functional user interfaces. In Proceedings of the 2001 Haskell Workshop, pages 41--69, 2001.Google Scholar
- Douglas Crockford. JavaScript: The Good Parts. O'Reilly Media, Inc., 2008. ISBN 0596517742. Google Scholar
Digital Library
- David Flanagan. JavaScript: The Definitive Guide. O'Reilly Media, Inc., 2006. ISBN 0596101996. Google Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Directing JavaScript with arrows
Recommendations
Directing JavaScript with arrows
DLS '09: Proceedings of the 5th symposium on Dynamic languagesJavaScript 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 ...







Comments