r/java • • 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

379 comments sorted by

View all comments

Show parent comments

49

u/CraftyAdventurer Sep 10 '21

The issue has more to do with verbosity and encapsulating everything in classes and having lots of configurations than with types themselves.

I was on both sides, Java and JS/TS (and even some Kotlin and C#). In Js world, many things are easy to do from the top of your head, so I feel way more productive just writing the code. In Java, I always have to reference a guide, tutorial, documentation or an existing projects to do a lot of stuff. I feel like I spend too much time on that.

The best example I can think of is JWT. When using express, all I had to do was create a middleware which validates received jwt, it's very easy because middleware is just a function with request and response objects. So you basically write

function jwtMiddleware(req: RequstType, res: ResponseType, next: NextFunction) {
const jwt = req.getHeader('Authorization')
const isJwtValid = validateJwt(jwt)
if (isJwtValid) next();
else res.send(401)

}

And that's it. That's something I can write in under a minute from the top of my head. There's nothing specific I have to remember about that, it's a function with three parameters. And it uses Typescript, which doesn't increase verbosity almost at all.

Also, inserting middleware in the express code is extremely easy, you just call those functions before or after the API routes (or inside a route if you want something specific), depending on when you want to run them. That's intuitive to me. I can just open a main file in any project and immediately see the order of middleware.

In Spring, I wanted to do the same thing. But I had to configure Spring Security first, which means I have to learn basics of that (well not really, could just copy it, but I like to know and understand what I write). After that, I had to create a class which extends OncePerRequestFilter which acts as a middleware, but it's already much more verbose than a simple (req, res) function, because I can't just create a function, I need to extend a class called OncePerRequestFilter and override it's method, and put it in a specific place in Spring Security configuration, and so on and so forth.None of these things take under a minute, and I still don't know how to do that from the top of my head, I always need to refer back to the specific project or tutorial and copy most of the stuff. I know how it works, I just don't know how to write it myself because there are more files to create, more methods and classes whose names I have to remember and configurations I have to do.

Also, from what I saw, when you write those filters, you can @ Order annotation. Meaning that there could be many of those classes spread out all over the codebase, and if I want to know in which order they run, I have to manually search for them.

I still prefer Java over JavaScript, mostly for it's more stable and mature ecosystem, but some things to me are just not intuitive. Yes, those are mostly related to Spring and not Java itself, but most of the jobs use Spring anyway so there's that.

Sorry for the long comment :)
Edit: code formatting

30

u/[deleted] Sep 10 '21

Woah woah woah woah...woah...woah. Woah. Hold on there cowboy. Don't blame Java for Spring. Spring is not Java's fault.

-16

u/towelrod Sep 10 '21

That is exactly the problem for me. Java the language is great, but the ecosystem around it is hot garbage. Spring is awful, maven is awful. That stuff is everywhere and has infected the programming style of every Java developer

It’s pretty much been like this since the early EJB days

9

u/kiteboarderni Sep 10 '21

You are probably the only person I have heard saying that java has a bad eco system 😂😂

-1

u/towelrod Sep 10 '21

Java has a great standard library, and has third party code for everything. That part is great.

But maven is awful to work with, and the large things like Spring are so ridiculously over done.

11

u/passive_talker Sep 10 '21

I don't know what you are comparing it with but maven is miles ahead of npm in every aspect I can think of, except that it uses XML.

1

u/kiteboarderni Sep 10 '21

Those are libraries. Of which their are numerous alternatives. Ecosystem includes ides, profilers, jdks, memory analysis tools, process monitoring. All of which even come in the bin dir of the jdk. Along with many other 3rd party options. The fact you think java bad because of maven and spring shows your inexperience.

-2

u/towelrod Sep 10 '21

I explicitly said Java is a great language. I don’t like to use the cruft that comes with it, though, like maven or spring. You can’t really be a professional Java developer these days without interacting with that stuff, that’s the problem

I don’t know why all the people in CS based jobs forums would be against Java (I think that is what we are talking about?). But I can say for myself, 25 years into professional software development, those things are the reason I don’t like Java. Just like an ancient parent in this thread said, it’s when you have to implement some code interacting with JWT or Okta or Oauth or any of the other stuff around enterprise software, it is much harder in Java than basically any other language in common use.

→ More replies (2)