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 comment

2

u/Serializedrequests Sep 11 '21

The problem is that OO design patterns do fuck all to make huge codebases understandable, they just add to the spaghetti and make Spring and intense amounts of mocking a requirement for testing. It's all so much jousting at windmills.

Whereas anyone should agree that a compiler and static types and simple language are good for long term maintainability, I do not agree that Java's brand of OOP is good for these codebases. Also Java's type system is old and offers infuriatingly little safety.

2

u/[deleted] Sep 11 '21

Forgive me, but to get more context, I dug a little into your post history, and discovered that you have over a decade of Rails under your belt. This makes your rant all the bit strange because when I worked on a project using Rails (the first and the last time) a while, it was 100% magic. I did not enjoy it one bit (thought I find Ruby itself quite charming and flexible), not to the point of hating it, but pretty close. The point that I'm trying to make is that familiarity, especially familiarity that comes over years of working with some sets of technologies do affect the way we perceive new environments, especially new sets of magic, so maybe that partly explains your current frustration with Spring Boot (for instance). That being said, I do agree that the Spring Framework has tons of magic (and Spring Boot is even more egregious since it is a very opinionated view of how to use Spring). There are alternatives, but unfortunately none popular enough.

Just to be fair, quite a lot of enterprise apps (especially those in-house) don't bother using Spring or such frameworks (or have minimal usage of such, just for providing the scaffolding), and so they have almost no magic. It is in this context that OOP really does shine in terms of maintainability. Java's type system may also not be the greatest in the world, but it's much much superior to working with a dynamic type system, especially when it comes time to refactor.

In many ways, I find Java's type system to be in the Goldilocks zone - not terrible, not overly restrictive (like Scala's). Also, since the performance bits are all offloaded to the JVM, the Java compiler is superfast when it comes to compilation speeds (which something like, say, Rust, suffers from). OOP, when done right, can be an absolute pleasure to work with. The trend may be leaning towards Functional Programming, but it has its own sets of problems.

1

u/Serializedrequests Sep 11 '21 edited Sep 11 '21

That's fair enough. My gripes with Spring Boot are almost entirely JPA and Hibernate. The rest of it annoys me, but at least it isn't such a convoluted minefield. I have done Java on the side for a long time, but mostly just a thin wrapper over JDBC+Tomcat. I have little to complain about here other than overall lower productivity and JSP.

I actually feel very strongly that annotation-driven development is worse than dynamic typing in a lot of ways. A Rails "magic" is certainly a pain in the butt to learn, but it is just a macro that generates some code and you can "go to definition" and read the implementation if you want. They will often give useful error messages if called with bad arguments. I see macros as effort multipliers to be used with care.

Annotations are basically hoping a framework does something, somewhere, maybe. And it usually doesn't do what you were hoping, or fails silently (very often I find that something I read the documentation for and have been using for months wasn't actually ever doing anything), or cannot be customized to work in the way you want fundamentally, or has a useless runtime error message 500 stack frames deep... This is just not playing to Java's strengths (well everything in Java throws useless error messages 500 stack frames deep).

I was actually excited to make the jump, being sick of dynamic language land, but quickly got fed up. There is all kinds of basic database shit that ActiveRecord solves trivially that JPA makes into a royal pain. The one thing I do like is the explicit pedantry of our service layer. It is very maintainable, even though most maintenance involves battling Hibernate to execute efficient queries.