AndroIdiots Podcast 11: Functional & Reactive Programming

Tushar Gupta
Dec 24, 2018 · 4 min read

Yes, Functional & Reactive Programming isn’t for the faint heart. There, I said it. This is the first question that pops into mind as soon as we see the words “Reactive Programming”. But then what is the point of learning it. This is what we are going to explore in our new episode with Ashish Krishnan & Gurpreet Singh from Kite & Amanjeet Singh from 1mg.

Image Credits: https://quickbirdstudios.com/blog/what-is-functional-reactive-programming-frp/

Show Notes:

These are difficult because of the way we have been taught programming from our childhood. Object-Oriented & Imperative Paradigms have been dominating from a few decades but times are changing. CPUs have becomes multi-core instead of getting faster and Memory has become cheap. Systems are not synchronous anymore but fast, responsive and async. We need an easy way to deal with all the asynchrony in the world and this is where ReactiveX (Reactive Extensions) have helped us.

ReactiveX have made it very easy to write reactive code in most of our imperative languages by providing a set of tools which work on streams of data whether synchronous or asynchronous. RxJava is the API for Asynchronous programming with observable streams for Java language. RxKotlin enhances usage of RxJava API in a beautiful Kotlinish way but works with RxJava.

ReactiveX is the combination of the best ideas from
the Observer pattern, the Iterator pattern, and functional programming. How so?. We discuss that in the podcast.

Observables: Data streams that we hook into. These emits data/events which we listen to and operate upon. Remember subscribing to articles or newsletters online. Yeah those are our observables.

Operators: This is where Rx borrows stuff from Functional world. Operators are functions, mostly pure, which allow operating on data emitted by Observables. flatMap , map are just some basic examples. There a lot more which make Rx really fun. Ever used a reader view in your browser to get rid of all the noise in an article and just focus on content. That’s an operator.

Observer: These consume the data and are on the consumer end of the Data streams. Consuming your subscribed article makes you an observer. Someday your subscription will end or you will terminate it, till then the stream lives and keep pushing data down the pipeline.

Schedulers: Rx has given us a very easy to add thread management to Observables. With just two lines of code we can subscribe to a data stream and perform heavy operations on it on another thread, and observe the data back on our main thread.

Android is completely asynchronous. Touch events, Activity Life-cycle, Network Operations, Sensor updates everything is async and provides a callback. So how do we compose so many different types of callbacks into a single, composable & simple understandable form. We could make everything Observable because everything is essentially an Observable in Android. It saves us from a ton of Callback Hell.

And above all, we have a single main thread available to us for all operations. Easy asynchronous programming with Rx helps us switch between background thread to main thread and keep our UI jank free.

RxAndroid provides Android specific bindings for RxJava that make writing reactive components in Android applications easy and hassle-free.

There is a lot more to Rx like BackPressure handling, concept of Subjects, Observables vs Flowables vs Singles vs Maybe etc. We do discuss these a bit in our podcast episode but these concepts are a bit advanced and should be learnt slowly.

Our guests and your hosts have prepared a very nice list of articles and websites to start learning Rx today.

Beginner friendly:
1. What is Reactive Programming?
2. Reactive Programming for Android
3. Wrapping your brain around F&RP
4. Introduction to Reactive World
5. Be Reactive Series. Part-I, Part-II, Part-III
6. Interactive Marbles diagrams to understand Reactive Operators
7. Mind blowing Rx Operators via Animations.
8. An effort by Amanjeet Singh to show Rx Operators via Animations on an Android App called RxAnime. Feel free to send pull requests.

A bit Advanced:
1. Reactive Manifesto
2. Reactive Specifications on JVM
3. Advanced RxJava Android Samples by Kaushik Gopal

Some great talks:
1. What if user was a function — A great talk by André Staltz
2. Managing State — By God himself: Jake Wharton

Book you can refer:
1. Reactive Programming in Java

This was an amazing episode and we learned a lot from our guests.
You can follow the Subject Matter Experts on these platforms:

Gurpreet Singh: Twitter, Linkedin
Ashish Krishnan: Twitter, Linkedin
Amanjeet Singh: Twitter, Linkedin, Github

Happy faces from Left: Gurpreet, Ashish & Amanjeet

We are inviting Android Developers to contribute back to the community via AndroIDIOTS. If you are interested in recording a podcast or writing tech articles, we would love to have you on board. Here is a small form you can fill so we can get back to you:

Follow us on twitter for regular updates and feel free to DM the hosts (Anupam & Tushar) for any queries.

Cheers!!

AndroIDIOTS

An android developer publication to stay updated with whats…

AndroIDIOTS

An android developer publication to stay updated with whats new in android, best practices and how to become a better android developer

Tushar Gupta

Written by

Self-Taught iOS & Android Dev | co-creator AndroIDIOTS | Functional Programming enthusiast | Enjoy diving deep into Architecture & Programming Languages.

AndroIDIOTS

An android developer publication to stay updated with whats new in android, best practices and how to become a better android developer

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store