34

I see many frameworks/libraries that claim that they can help build reactive applications in Java, such as: Akka, Vert.x, RxJava, Reactor, QBit, etc.

They seem to have different approaches, features, pros, cons, etc. I could not find detailled comparisons. There is documentation about each of these framerwork, but it is not enough for me to understand the differences.

What are the differences between the major Java reactive frameworks?

And what are the application requirements that can drive the choice of a Java reactive framework?

Thank you for your time.

Florian Beaufumé
  • 1,751
  • 2
  • 22
  • 34
  • 1
    While akka is for java, its core is built using scala and the actor model.It shines when using scala since it is more naturally suited for functional programming. Akka users actor model, whereas RxJava uses something called observer pattern.If you are using scala then choose Akka, if you are a java shop then choose RxJava.Both are used by some big names and are well suited for production systems. – Madusudanan Nov 12 '15 at 12:57
  • 1
    By the way, I'm fine with questions like this, but the purists on SO might label this question as being too open-ended. Just a heads up. – Matt Passell Nov 12 '15 at 15:29
  • Whatever you use, you still need to generate the stream. Have a look at this article I wrote last month: http://www.coopsoft.com/ar/ReactiveArticle.html – edharned Nov 12 '15 at 22:49
  • Thank yous guys for the extra info. – Florian Beaufumé Nov 16 '15 at 16:38
  • I wrote a comparison article between RxJava2/Reactor and Akka Streams API. Perhaps it's useful: https://gitlab.com/artur.jablonski.pl/akka_streams_vs_rx_reactor – artur Aug 20 '19 at 21:43

1 Answers1

39

I'm working on RxJava and I did some evaluations on Akka-Streams and Reactor recently.

As far as I can tell with all the libraries, they converge to a single concept called Reactive-Streams so you can go back and forth between the implementations.

I believe RxJava is the most generic of all, has zero dependencies on other libraries and is not opinionated about concurrency. It is very popular on Android mainly due to support by other libraries/frameworks such as Retrofit. The 1.x branch doesn't implement Reactive-Streams but has wrappers for it whereas 2.x is natively Reactive-Streams compliant (currently available in preview). Many popular JVM-based programming languages have adaptors for it (Scala, Kotlin, Clojure, etc).

Reactor is Reactive-Streams compliant as it is more recent library. They have dependencies/support for a lot of other libraries. They chose a different set of tradeoffs when it comes to concurrency and queueing in the streams (i.e., LMAX Disruptor-style). There were a few back and forth between it and RxJava regarding operators and we've started talking about having a shared pool of operators.

Akka is highly dominated by Scala-like concepts; I had a small trouble getting it to work. The team behind it were involved in developing the Reactive-Streams specification and there is an Akka-Streams library that is advertised to support Reactive-Streams, however, accessing it is cumbersome because its fluent API is heavily intertwined with the Akka actor model.

If you are on the server/desktop/Android side, RxJava is generally a good choice (and I believe is documented better than the others) and is aimed at high-throughput asynchronous operations. If you are more on the latency side, Reactor might be a better choice. I don't know much about the usages of Akka-Streams but I saw one benchmark a year ago where a web-server built around Akka outperformed Tomcat and Netty+RxJava.

akarnokd
  • 69,132
  • 14
  • 157
  • 192
  • 4
    Coming across this popular answer, I wanted to point out that since then Reactor has evolved to be more similar to RxJava2, as Reactor 3 (fully implementing reactive-streams, a lot of operator vocabulary in common, no dependencies, but based on java 8) – Simon Baslé Mar 31 '17 at 08:12