Hi there! How are you? I hope you are well!
Recently, I am looking for better ways to interact with APIs, handle I/O and general async operations inside an application. I came across the concept of Reactive programming while I was trying to understand how RxJs works! Of course these two words refer to completely different things. This is the goal of this article, to understand better which are the differences between them and clarify things in order to dive deeper in future posts!
This term refers to a programming paradigm! We cannot argue enough at this point so our next question is:
What is a programming paradigm?
So, going back to our original question about what Reactive programming is we can say it is a different programming paradigm than OOP or Imperative programming or even Functional programming! Ok so far, but the next question is this:
What is the mental shift for this paradigm?
The base concept of Reactive programming is the data stream (or Observable in RxJs)! We can say that a data stream is the core type of this paradigm, analogous to object for OOP and function for Functional programming! But what is a data stream?
According to Wikipedia, a stream is a sequence of data elements made available over time! And this is the huge difference in the mental model! In other paradigms, we think of data as single values or chunks. In Reactive programming there is a continuous flow of data like a water stream! We think of data as collections of elements over time! This introduces us to another notion. How do we communicate the data flow changes through our system? With the help of the Push protocol! Oh dear!
A Push system is similar to the Observer OOP pattern! What is the Observer pattern, right?
I think this is a good place to take a break and continue to the next post in what seems like a series of posts eventually!
So, until next time…