Why ReactiveX is the only Functional Programming library you must Learn
An overview of Functional Programming
Ask any programmer who has heard about Functional Programming (FP) and you’re likely to get one of two reactions: either they have tried it and love it, or they have heard of these mythical creatures called functional programmers that eschew the use of classes and objects in favor of an approach full of functions. Functions everywhere.
Before getting into functional programming, I thought curry was a spice powder. Now I realize it’s a way of building a blockchain of functions with immutable state. Mind blown! Currying and immutability are the two biggest strengths of functional programming, and I wanted a practical way to use them in everyday application code. Functional programming was still too theoretical for me, but now I could at least see where I was using it and recognize its patterns. My eyes had been opened. I felt like I had awakened and saw the matrix. I was already using functional programming. It was Everywhere!
Where does Reactive come into Functional Programming?
Before getting into examples of famous libraries that use functional programming, it’s worth mentioning that one of the best use cases of functional programming is within the context of a reactive environment with asynchronous data flows like User Interfaces and web servers. These areas are also where a good chunk of professional programmers are employed now. If we can reduce bugs in our code with functional programming and ship better, more usable software, then a few hours of learning is worth giving our users a better experience.
A Friendly and Practical functional programming ecosystem that is truly Cross-Platform
Although learning to use RxJS effectively is by no means easy, one of the most motivational things that kept me going was the colorful stream diagrams and the wealth of resources available for learning it. It was almost as though the community was saying, “Hey we know this is hard, but colorful pictures! Data is just a stream!” Then things started to make sense, and my programming became much more predictable. Thinking of data as a stream that you route with functions like map and filter changes your programming style. You organize your files more deliberately. You can start writing shorter blocks of code that do much more, like one-line loops that are actually readable with ‘map’.
With an FRP library like ReactiveX, we can use the comprehensive tool chest to build our own custom functions. We can start recording the programming patterns we use in our code to handle data and reuse them anywhere we need to. It helps us visualize data for what it really is, free from each language’s arbitrary constructs. It helps us see the matrix.