What’s the meaning of Reactive-Programming?

Ramesh Katiyar
5 min readNov 22, 2019

Whenever I’m trying to learn new technology, I struggle with some confusion that, what really it’s meaning or where should I apply it? I try to connect it with which I already know. I get lots of questions about that. The same confusion or struggle I was facing when I started reading about Reactive Programing. If this happens with you also, then this blog is for you to understand, “What is the Reactive Programing?” in a simple way.

I’ve read it from different documentation, blogs, and videos. Here I’m going to share my understanding of reactive programming. It will help you to make it clear. After that, you can also go ahead and figure out yourself to learn more.

So let’s start!

What is Reactive Programming?

Reactive programming is not a new programming paradigm. In our computer field, we give the new name to which we already doing and people are excited about that. Reactive programming is the same example.

Here Reactive means, “Response to an action”. So, reactive programming is a rehashed programming model, which focuses on some key things and brings some set of best practices together which we already know.

Reactive Programing = Set of best practices [Elastic, Resilient, Responsiveness, Message-Driven]

In different words, it is an architecture that focuses on the elastic, resilient, message-driven, and responsiveness, so that the application can quickly react on the action or things happening and provide a greater fast response.

How is it different from what we used to do?

Here I got to know that what it’s really mean to code in reactive programming and how it is different or similar form what we already do?

So what I understood is, If you look around 20+ years ago, you will see that we were implementing mostly CRUD types application. Means, using the MVC design pattern we were reading data from DB and showing on View. Or taking input from View and inserting or updating into DB. But do you really think now also we have only those types of use cases or applications?

There are several applications where CRUD does not make any sense or maybe not for the entire application scope. There could be few parts of the application where CRUD will not work. For example, if we want to create a small application or feature as a processing unit, where we don’t care about data in the database. But we are interested in where some kind of data flowing in the processing unit and this processing unit performs some kind of operation and sends some kind of data out.

Here we don’t care about, from where data is coming and where it is going. We just care about the middle part where we processing those data effectively. Here the input data is flowing constantly and we are not requesting for each data. Simply we have this data flow-through and we are going to process this data as a flow-through then send an output.

Now if you look around the world, there are many real-world applications where we need these types of features. To understand more it, we can take an example of radio broadcasting. They broadcast the radio stream data constantly and not waiting for that our radio is on or off.

It means the world around us is full of these streams of data. And in current days and future, we have to implement applications such that they can deal with big data or stream of data. The best example is twitter. In twitter, once you follow or subscribe, you continuously get the updates or stream of data. You keep scrolling and it keeps giving the new updates. This means data is flowing through. Here you can also put the filter like, I’m interested in only these types of info. So it means, you are not interested in everything but interested on specific info. Using reactive programming, we can achieve these types of use cases.

Why we need it?

The main reason the world is changing very fast. And now and in the future, we have to deal with the streams of data or big data effectively. But our goal should not be making the existing application as a reactive application. We should replace existing solutions which not make sense for the above cases of stream data. So, reactive programming helps to create a reactive application or system, which mainly focus on four things in the application.

  • Elastic: Means how you are going to handle the high load on your system? This means your reactive application should be responsive at a higher load. Also, it should be able to scale up or down according to load requirements.
  • Message Driven: In our system, the different components or services should communicate through asynchronous message passing rather than using the centralize database system schemas to talk. Because if one schema changes happen, the entire system will down. So we should make sure that different micro-services or components should be loosely coupled.
  • Responsive: In today’s world, most of the application lose the users because of slow response. Because nowadays, users do not want to wait. So your application should be a quick response to the user request. A good example of responsiveness is infinite scrolling. This means here, efficiency is not doing task faster, but avoiding those tasks in the first place.
  • Resilient: Your application should able to handle the errors and exceptions properly. This means it should be responsive at the time of error or any issue.

So, Reactive Application is easy to response on any request or events happen, it can handle the failures in a great manner, and it can deal with high load of users.

Implementation of reactive programming

ReactiveX is the library that supports reactive programming for composing asynchronous and event-based programs by using observable sequences. It is implemented tools for reactive programming in different programming languages.

Few tools for reactive programming are:

  • RxJava
  • Rx.NET
  • RxScala
  • RxJS and few others.

In my next blog, I’ll explain one of these tools that, how we can use it or start writing a reactive program?

--

--

Ramesh Katiyar

Interested in learning and exploring new technologies and skills.