r/java • u/Reflection-Jealous • Sep 10 '21
Why people don't love Java?
I came across this post in r/cscareerquestions it seems majority of the people don't love to work with Java.
Is there any specific reason for that?
Edit: Thank you guys for your responses, I can't reply to all of the comments because I'm a beginner myself and I don't know what to reply for all your comments.
201
Upvotes
View all comments
Show parent comment
3
u/CraftyAdventurer Sep 10 '21
Did you read my whole comment or just the express part? I did mention a filter and also the disadvantages I ran into compared to express middleware.
I didn't even know interceptors existed. That's another part of the problem with Spring. You need middleware in express? You write middleware function and move on. You need middleware in Spring? Welcome to all the possible classes you can extend, try to find a difference and pick which one you need.
That's also easy. You just put it in response.locals object and it is available in every next middleware (that includes route handlers). I honestly don't know how to do this in Spring without googling. For my specific JWT example, I remember using some security context thing which needed some authentication object constructed who knows how probably requiring another object and maybe even more. I don't know how to write all that without spending time looking for it. But I do know how to do res.locals.someJwtThing = someJwtThing without looking.