39

Today I found that, for concurrency in java we have good framework like Akka and I also found that, there is a reactive programming frameworks like RxJava for performing multithreading in application. But I'm still confused! Why are both better than Java Concurrency framework?

Nowadays reactive programing is mature topic, and most languages have support for Functional Reactive Programing like Netflix provide APIs regarding Reactive programming for more than one language. Rxjava is one of the api that is used for java, scala etc. According to RxJava, they internally use actors for maintaining multithreading and Akka also uses Actors for multithreading programming.

So, what is the difference between Akka and Reactive Programming approach and why they are good from Java Concurrency ?

Vishal Verma
  • 962
  • 8
  • 18
Harmeet Singh Taara
  • 6,483
  • 20
  • 73
  • 126
  • 3
    Unclear; and ultimately, choosing this or that solution depends on your needs. – fge Dec 17 '14 at 12:44
  • ok, But which approach is good, reactive programming, akka or java concurrency ? because they all provide `multithreading`. – Harmeet Singh Taara Dec 17 '14 at 12:58
  • There is no general "good approach"; just go with what you are familiar with and/or want to do. Personally, I just use what the JDK provides since it is good enough for my needs, and that's about it. – fge Dec 17 '14 at 13:00
  • @fge the thing is that, why `akka` and `reactive programming` is popular in now day's? most of the good developers suggest to follow reactive approach. – Harmeet Singh Taara Dec 17 '14 at 13:11
  • 1
    Well, I don't know whether I'm a "good developer" but I wouldn't recommend any of them, because I don't use them and don't need them. And as far as concurrency is concerned, you want to (buy and) read "Java Concurrency In Practice" by Brian Goetz. – fge Dec 17 '14 at 13:12
  • 1
    yes i have this book, this book is really awesome, and i am not said like that you are not a `good developer`. sorry if i heart you. but evolution is the part of development. and i just still want to know that, why we preferred them. – Harmeet Singh Taara Dec 17 '14 at 13:20

2 Answers2

23

According to Mathias Doenitz at this point in time RxJava doesn't have back pressure unlike Akkas Reactive Streams implementation. But RxJava seems to be working on adding back pressure.

Both frameworks will be able to interact through the reactive streaming spi. So you will be able to do very very similar things. According to Mathias the difference will be that the Akka implementation is based internally on actors, not on multi-threading. And as a result will be more performant.

My source for this information is a talk that Mathias gave last week at the Dutch Scala user group.

edit: I stand corrected wrt back pressure support in RxJava. If you follow Eriks link you can read what back pressure means.

Ismail Marmoush
  • 13,140
  • 25
  • 80
  • 114
Joost de Vries
  • 640
  • 6
  • 8
  • 1
    rxJava2.x has back pressure support. – happyyangyuan Apr 12 '18 at 03:41
  • 3
    "According to Mathias Doenitz at this point in time RxJava doesn't have back pressure" That is factually incorrect; https://github.com/ReactiveX/RxJava/wiki/Backpressure – headinthebox Dec 18 '14 at 00:52
  • RxJava is also not based on multi-threading. Please update the answer to accurately reflect current reality. Appending an edit comment is misleading. – Charlie Jul 25 '22 at 16:23
1

Akka Streams being based on actors provides interop between actors and streams, e.g.:

  • reading from actor and passing it to streams and
  • reading from streams and passing it to actors
denis631
  • 1,765
  • 3
  • 17
  • 38