Please, can somebody explain me what are the advantages of using reactive style:
Observable<String> greeting = Observable.just("Hello");
Observable<String> yelling = greeting.map(s -> s.toUppercase());
instead of simple imperative style:
String greeting = "Hello";
String yelling = greeting.toUppercase();
I understand reactive programming like the same “API” for database access, UI, computation, network access and etc. But why we need to use reactive programming for simple toUppercase
Apart of all no blocking features, another great feature to use Reactive programing, is the important use of backpressure. Normally is used in situations where your publisher emit more information than your consumer can process.
So having this mechanism you can control the flow of traffic between both and avoid the nasty out of memory problems.
You can see some practicle examples of Reactive programing here https://github.com/politrons/reactive
And about back pressure here https://github.com/politrons/Akka/blob/master/src/main/scala/stream/BackPressure.scala
By the way, the only disadvantage about reactive programing, is the curve of learning because you´re changing paradigm of programing. But nowadays all important companies respect and follow the reactive manifesto http://www.reactivemanifesto.org/
If you want to see some practical examples you can reference here https://github.com/politrons/reactive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With