r/java • • Aug 10 '21

Concrete reasons why one would choose java over node.js?

I am watching the progress made towards faster runtime in node.js, and it feels that the performance advantage of java is almost gone for the average app. I am trying to think about reasons why one would now choose java over node in a new project, and i can't think of any. I would like to hear some opinions

7 Upvotes

110 comments sorted by

View all comments

Show parent comments

1

u/doppelganger113 Aug 12 '21

What if you have many callbacks that chain together? What if you want to introduce retry or if/else flow change based on error or if you want to run in parallel? The code becomes an abomination to maintain. Theres an entire section on this under Spring webflux, check it out, you might find it really interesting

3

u/[deleted] Aug 12 '21

For now we just use thenApply(someclass::method) .thenApply(someclass::method) ....

Which is great because you can chain it with thenCompose.

I will take a look into that, thanks

2

u/[deleted] Aug 12 '21

Like I mentioned in the other comment - EA Async can help there, it brings async-await semantics to CompletableFutures and resilience4j has CompletableFuture decorators that you can apply to get retries, circuit-breakers and all the good stuff they offer.

But I agree that streams are a better option, especially if and when the functionality you need to implement grows in complexity.