Tutorial: Prof. Mark Lewis
Author of Book "Introduction to the Art of Programming Using Scala" (CRC Press)
Date & Time: July 25 (Monday), 2016; 05:40pm - 08:30pm
LOCATION: Copper Room
As the need to get programs to scale to handling larger amounts of data/requests has grown, the area of “reactive” programming has grown. This approach to software development is embodied in the “Reactive Manifesto” (www.reactivemanifesto.org), which lists four key aspects of reactive systems. They state that these systems are responsive, resilient, elastic, and message driven. Responsive implies that requests to them are served quickly. Resilient means that they deal well with failure, assuming that it isn’t possible to completely avoid problems. Elastic implies that they can respond to changes in demand by scaling both up and out as needed. Message driven describes the style in which reactive systems are constructed.
The Play Framework is a full stack framework for the JVM. It happens to be the only JVM web stack that was built with the intention of being fully reactive. It has been used to build sites such as LinkedIn, Klout, The Guardian, and Walmart Canada. Much of the reactive nature of Play comes from the fact that it is built on Akka, a library for Actor parallelism on the JVM.
The purpose of this tutorial is to give attendees an introduction to reactive programming, the Play Framework, and the Akka library. We begin by giving an overview of what makes an application reactive as well as how and why we strive to achieve that. We will then look at building a basic Play web application. This discussion will demonstrate the MVC nature of Play, examining how it handles aspects like routing and view templates. We will also explore the aspects of the full stack that help it to support reactive programming. This will start at the bottom of the stack with Netty NIO client server framework through database interactions.
A big part of any reactive application is the ability to schedule tasks for later processing after some other work has been completed. In Play, this functionality is provided by Scala/Akka Futures. These Futures are monads that can be easily composed to build up complex logic, and they intentionally make it difficult to block one wait on their results. Instead, the Play Framework has built in support for Futures so that the application programmer never has to worry about pulling out values at the end of the computation.
One of slower operations involved in web applications is database queries. We will look at the Slick database binding as an option for interacting with databases in a reactive way using Scala. Slick utilized Futures to prevent blocking threads. It also has an interface called lifted embedding that makes database interactions typesafe as well as reactive.
Lastly, we will explore the Akka library that underlies much of the parallelism in Play. Akka is an Actor based parallel library, that utilizes message passing to produce race condition free multithreaded computations. Recently, the library has gained reactive streaming capabilities and RESTful API building capabilities through Akka HTTP. The capabilities of these for developing reactive APIs will be briefly discussed as time allows.
Anyone who is working on web development or high throughput data processing.
Biography of the presenter
Mark Lewis has been teaching Computer Science at Trinity University since 2001. His courses span from introductory to advanced and tend to focus on aspects related to programming/programming languages, including web development, and simulation/scientific computing. He has been the lead author on over 20 papers spanning a range of topics from planetary ring dynamics in the journal Icarus to the SIGCSE annual conference proceedings. He is also the author of “Introduction to the Art of Programming Using Scala,” published by CRC Press.