Hands-On Reactive Programming in Spring 5
上QQ阅读APP看书,第一时间看更新

Brief history of reactive libraries

Now that we are acquainted with RxJava and have even written a few reactive workflows, let's look at its history to recognize the context in which reactive programming was born and the problems it was designed to solve.

Curiously, the RxJava history and the history of reactive programming as we know it today began inside of Microsoft. In 2005, Erik Meijer and his Cloud Programmability Team were experimenting with programming models appropriate for building large-scale asynchronous and data-intensive internet service architectures. After some years of experimenting, the first version of the Rx library was born in the summer of 2007. An additional two years were devoted to different aspects of the library, including multithreading and cooperative re-scheduling. The first public version of Rx.NET was shipped on November 18, 2009. Later, Microsoft ported the library to different languages, such as JavaScript, C++, Ruby, and Objective-C, and also to the Windows Phone platform. As Rx began to gain popularity, Microsoft open sourced Rx.NET in the fall of 2012.

To read more about the birth of Rx library, please read Erik Meijer's foreword in  Reactive Programming with RxJava  by Tomasz Nurkiewicz and Ben Christensen.

At some point, Rx's ideas spread outside of Microsoft, and Paul Betts with Justin Spahr-Summers from the GitHub Inc. company implemented and released ReactiveCocoa for Objective-C in 2012. At the same time, Ben Christensen from Netflix ported Rx.NET to the Java platform and, in early 2013, open sourced the RxJava library on GitHub.

At that time, Netflix was facing the very complicated problem of handling the tremendous amount of internet traffic generated by streaming media. An asynchronous reactive library called RxJava helped them to build the reactive system that boasted a 37% share of internet traffic in North America in 2015! Now, a huge part of the traffic in the system is handled with RxJava. To withstand all of that enormous load, Netflix had to invent new architecture patterns and implement them in libraries. The most well-known of these are the following:

In all cases, RxJava is a crucial ingredient of named libraries and consequently the whole Netflix ecosystem itself. Netflix's success with microservices and streaming architecture pushed other companies to adopt the same approaches, including RxJava.

Today, RxJava is used natively in some NoSQL Java drivers, such as Couchbase (https://blog.couchbase.com/why-couchbase-chose-rxjava-new-java-sdk/) and MongoDB (https://mongodb.github.io/mongo-java-driver-rx/).

It is also important to note that RxJava was welcomed by Android developers and companies such as SoundCloud, Square, NYT, and SeatGeek to implement their mobile applications with RxJava. Such active involvement lead to the appearance of the viral library called RxAndroid. This simplifies the process of writing reactive applications in Android quite significantly. On the iOS platform, developers have RxSwift, the Swift variant of the Rx library.

At the moment, it is hard to find a popular programming language without the Rx library ported to it. In the Java world, we have RxScala, RxGroovy, RxClojure, RxKotlin, and RxJRuby, and this list is far from completion. To find an Rx implementation for our favorite language, refer to this web-page at http://reactivex.io/languages.html.

It would be unfair to say that RxJava was the first and only pioneer of reactive programming. Importantly, the wide-spread adoption of asynchronous programming created a solid foundation and demand for reactive techniques. Probably the most significant contribution in that direction was conducted by NodeJS and its community (https://nodejs.org).