Skip to content

Why I Hate RxJava

A few years ago some of the android apps I work on started using RxJava. At first I was excited… the concept seemed really elegant and getting rid of AsyncTasks and call-call-call-callbacks seemed like a Godsend. However, the shine wore off pretty fast and eventually turned opposite. Here are some of the major drawbacks I’ve found with it.

  • The learning curve is incredibly steep. Of all “new” tech I’ve helped adopt in the last few years, and possible in my entire career, RxJava is the hardest to learn, I think for a few reasons.
    • It isn’t very intuitive, especially for people that have backgrounds in… anything else (procedural/functional/object oriented/etc). Even after working with it a few years, I still have to open an RxJava “scratch pad” project to try to puzzle out certain behaviors by writing equivalent event streams using simple types and trivial functions
    • The API is ridiculous. For almost any method, your IDE presents an enormous list of possible next calls. For a novice it is overwhelming and even after working with it for a while the “right” thing to do isn’t always obvious
    • Behavior is really subtle, and you have to really understand how it works to avoid screwing things up. As one example, I recently fixed a bug caused by an event being created at subscribe time instead of “in the event stream” but it was extremely difficult to tell that was the issue just by inspection
    • Debugging is difficult since most code you write is at the bottom of an enormous stack with little surrounding context. Same goes for interpreting stack traces.
    • Error handling doesn’t work the same as any other Java code/framework I’ve ever seen, so is frequently done incorrectly or simply not at all (which sometimes can mean errors go undetected)
  • It doesn’t actually seem to solve the problem it claims to solve very well (multithreading). Sure – it is very easy to put some tasks/events on a background thread, but if you want to run MULTIPLE background threads, it gets very complicated in a hurry, and a deep understanding of error handling becomes critical to avoid having your stream disposed by an error in one thread
  • Calling it “an opinionated framework” is an insult to opinionated frameworks everywhere. Once RxJava is part of your API, good luck getting rid of it. You basically have to rewrite virtually everything to adopt a different programming style or even threading model.

There are definitely some classes of problems that seem like it is very well suited for, but for general purpose application development, blech.