First I have to say that I have not much experience with Reactive Programming.
Since there are only a few interfaces in JDK 9 (Flow and its nested interfaces), JDK 9 obviously does not include a reactive library like RxJava.
In the Javadoc, there are some examples for implentations of Publisher
, Subscription
, and Subscriber
. But these seem to be quite low-level and do not have any reactive operators or handling of back-pressure.
So what is the point of including those interfaces into the JDK?
Are vendors of reactive libraries supposed to use them, so that Java implementations (like RxJava) of those use a common set of interfaces? (similar to JPA and Hibernate?)
Flow API is official support for reactive streams specification since Java 9. It is a combination of both Iterator and Observer patterns. The Flow API is an interoperation specification and not an end-user API like RxJava.
The main goals for Java 9 are to: Make the Java Standard Edition platform, and the JDK, more navigable to scale down for small computing devices. Improve the overall security and maintain not only the JDK but the Java Implementations in general. Allow overall improved application performance.
RxJava is a Java library that enables Functional Reactive Programming in Android development. It raises the level of abstraction around threading in order to simplify the implementation of complex concurrent behavior.
It mainly allows Java itself to use reactive programming internally in some future version, such as Reactive JDBC, Networking, IO, etc. In concept, it also serves as a new rally point for interoperation, however, such rally point already exists with Reactive Streams targeting a much larger audience via its Java 6 requirement.
As you mentioned, having that 4 interfaces and the SubmissionPublisher
by itself has limited use. If Java had extension methods similar to Kotlin and C#, the inclusion of the interfaces could have much more interesting impact.
Unfortunately, it also means that existing libraries have to use bridges to convert between Java 9 Flow and Reactive-Streams and/or reimplement the whole library with Java 9 Flow API - cutting out anybody without Java 9 (i.e., Android).
Major libraries have already such bridges (RxJava 2 Jdk 9 Interop, Reactor-Core Interop) and the Reactive-Streams will have its own bridge eventually. There is also a prototype reactive library written for and with Java 9 features.
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