My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
What the heck is reactive programming ?

What the heck is reactive programming ?

Gowtham kumar's photo
Gowtham kumar
·Mar 5, 2017

What is Reactive Programming?

Reactive : rɪˈaktɪv/

Showing a response to a stimulus.

A response to an action

The newest programming trend.

So already we have Multi-paradigm programming, do we need know about it ? YES.

We have acquired lot of knowledge on different frameworks and different languages.But for the past 2 decades as far as i know we are using the same programming paradigm which haven’t changed.

Reactive extensions are used by Microsoft,Netflix as internal project. The problem Netflix people faced is that their products are based on streaming they observed that there’s a gap to fill between client and server which is latency.

Example:

Consider this scenario user have 4 gb ram and 40 mbps of internet connection . And opened your application there comes the splashcreen for 5 seconds and selects language preference a network call will be sent you wait for another 5 seconds, goes to tv shows and selects his fav TV another network call with progress bar.

User will uninstall the app in the next minute.

Consider another scenario as an android developer we tend to make lot of network calls. What if user makes a network call and moves out from the screen ? Your app will gets back data from server with lot of excitement and TADA! User is not on that screen! So we have wasted resources of the user’s mobile which commonly are network bandwidth, ram , blah blah.

Multi-paradigm programming

Multi paradigms are combination of many paradigms such as Object orientedor Imperative programming .Iterator is best example, It pulls the data from list or whatever data you pass it it. A traditional CRUD operations can also be considered.

It’s like your cat, doesn’t cares. it comes when it wants but not when you want.

Reactive programming

Client subscribes to the data and it won’t ask for it, Whenever there’s a change in data the server pushes the data to client.

It’s like your dog, lots of love immediately.

What makes difference using reactive programming ?

Event driven:

Example : You are writing a story in Medium, you suddenly closed the tab. Does it loses data ? NO. As it is event driven for every word you type there’s an event triggered and being saved, Same thing with the Google Docs.

But if you look applications like MS office which is developed on imperative paradigm, you need to save the data every time when you make change it, if there’s any power failure’s your work will all be gone by the time you start your system.

But in reactive programming everything is event driven as an example look at the applications like Google keep or Medium, you type the data for every space the data is getting saved. Pretty nice is n’t it ?

Resilient :

In object oriented programming you write lot of call backs to which will become real mess when you debug.Remember last time when you debugged your code with call backs within call back!!! But the error handling in Reactive programming is kind of hassle free.

That’s all folks. If you like this article please do share.

Think twice code once.