Introductory presentation for the Clash of Technologies: RxJS vs RxJava event organized by SoftServe @ betahouse (17.01.2015). Comparison document with questions & answers available here: https://docs.google.com/document/d/1VhuXJUcILsMSP4_6pCCXBP0X5lEVTsmLivKHcUkFvFY/edit#.
4. Reactive Programming
• In imperative programming languages
expressions are evaluated “in place”:
a = 10;
b = 20;
c = a + b; // c = 30
a = 40; // c = 30
5. Reactive Programming
• In reactive programming languages changes in
the data flow may trigger changes to multiple
variables:
a = 10;
b = 20;
c = a + b; // c = 30
a = 40; // c = 60
6. Reactive Programming
• Reactive programming may also refer to the
interaction between different systems or
components in a system
• In that regard the libraries we will be
discussing do not serve as a replacement of
message brokers (such as RabbitMQ, Kafka,
MSMQ and a number of others)
7. Reactive Programming
• In this clash we would refer to the
“programming language” - inferred meaning
behind reactive programming
10. Functional Reactive Programming
• A more common subset is functional reactive
programming (FRP) that makes use of streams
and stream operations for anything (input,
changes in variables and many more) in order
to achieve reactiveness
• Connal Elliot – ground-breaking paper
@Conference on Functional Programming,
1997
11. Functional Reactive Programming
• Reactive Programming = Programming with
Asynchronous Data Streams
• Functional Reactive Programming (FRP) =
programming paradigm for reactive programming
that uses the building blocks of functional
programming (e.g. map, reduce, filter). FRP has been
used for programming graphical user interfaces
(GUIs), robotics, and music, aiming to simplify these
problems by explicitly modeling time. [Wikipedia]
12. Functional Reactive Programming
• Reactive Programming = Programming with
Asynchronous Data Streams
• Functional Reactive Programming (FRP) =
programming paradigm for reactive programming
that uses the building blocks of functional
programming (e.g. map, reduce and filter)
13. Functional Reactive Programming
• FRP has been used in:
– responsive graphical user interfaces (GUIs)
– robotics
– the music industry
14. Functional Reactive Programming
• RxJava and RxJS implement the functional
reactive programming paradigm in terms of
libraries for the Java and JavaScript
programming languages correspondingly …
• Derived on the basis of Microsoft’s Reactive
Extensions (Rx) library for .NET
16. Functional Reactive Programming
• Rx has an implicit contract that must be
followed:
event source
OnNext(item) OnNext(item) OnNext(item)
OnCompleted()
OnError(Exception)
20. RxJava
Observable.from(new String[] {"Reactive",
"Extensions", "Java"})
.take(2)
.map(s -> s + " : on " + new Date())
.subscribe(s -> System.out.println(s));
Result:
Reactive : on Wed Jun 17 21:54:02
GMT+02:00 2015
Extensions : on Wed Jun 17 21:54:02
GMT+02:00 2015
21. RxJava
• Lambdas and streams introduced in Java 8
make the FRP style of programming in Java
easier to accomplish
• There is a proposal for introducing a reactive
streaming API as part of the core libraries in
JDK 9