Programmers-- are you sick of passing around state?
How much time do you spend maintaining state variables, tracking state variable values across multiple threads and asynchronous callbacks, and painstakingly caring for state variables until you accidentally feed one after midnight and it turns into a gremlin?
In many languages, it seems like our job as programmers is becoming more about passing state around than it is about writing business logic. Much of this is due to the added complexity caused by asynchronous callbacks.Reactive to the Rescue
There is another option. It is new paradigm called "reactive programming."
Reactive programming treats data variables as flows or streams of events over time. These event streams can be combined, filtered, mapped, and manipulated in many ways.
Reactive programming borrows ideas from functional languages like Haskell and Scala. However, the difficulty of writing programs with reactive extensions is greatly reduced because programs are still allowed to use easy concepts of "imperative" languages like variables, looping, and side effects.
Programming with streams requires far fewer state variables, offers thread safety benefits, and does not suffer from "callback hell."Who Uses This?
There are plenty of lesser-known companies who use reactive extensions. But there are more than a few household names as well.
"Netflix is a big believer in the Rx model, because Rx has made it much easier for us to build complex asynchronous programs. RxJava is effective on the server for us and it spreads deeper into our code the more we use it."
"Reactive Extensions is a set of libraries that makes asynchronous programming a lot easier. If asynchronous spaghetti code were a disease, Rx is the cure.”
"Using Rx and ReactiveUI, we've written a fast, nearly 100% asynchronous, responsive application, while still having 100% deterministic, reliable unit tests. The desktop developers at GitHub loved Rx so much that the Mac team created their own version and are now using it on the Mac to obtain similar benefits." What We'll Cover
We will start by discussing Java 8 streams. This will provide a quick introduction to the concepts.
Then we'll dive into Netflix's library providing reactive extensions to Java, RxJava. RxJava can do everything Java 8 streams can do, but do it asynchronously.
Finally, we'll explore Elm, a functional reactive programming language for the web that offers both two-way data binding similar to AngularJS and some truly unique features-- hot-swapping of running code and a time-traveling debugger. Elm's unusual features allow a programmer to make and observe program changes while the live program is running.Will I Benefit?
You should understand the concepts of programming in at least one language. Reactive extensions exist for more than a dozen languages, including the following list. These extensions offer a real paradigm shift for authoring asynchronous code, handling errors, and managing state.
True functional reactive programming (FRP) languages like Elm provide a real WOW factor for those who have never witnessed a time-traveling debugger in use. As a programmer, it would be hard to walk away from this session without learning something interesting.
I gave an Android-specific version of this talk in front of over 100 developers at AnDevCon 2014 in San Francisco and 96% of attendees gave positive reviews. Several tweeted that this talk was one of their favorites at the convention.
Learn more at ReactiveX.
Colin is an experienced software engineer specializing in Android development. He worked for Mozilla on the Firefox for Android browser rewrite. He has worked for many successful companies in the past fifteen years, including Amazon, Flipgrid (acquired by Microsoft), Cray, Pearson VUE, and When I Work. He runs the Twin Cities Kotlin User Group in his spare time.
Colin has a strong background in infosec as both a former Amazon security certifier and as a security expert on the Android team at Mozilla. Lately, he's been conducting code security reviews for PullRequest.
He has been programming since he learned BASIC on the TRS-80 computer in his parents' basement at age six. He has been writing Android apps since soon after the first Android phone launched and has done so professionally since the last space shuttle landed. In that time, he's probably been pitched every silly app idea.