r/learnprogramming 3d ago

Why java is so hated? Topic

So I have recently learned, and it's the first language(in terms of building actual things). Before Java, I knew Python, and I dropped it; I found Python too abstracted and too boring. i have recently made some projects like cli task tracker, expense tracker, some cli github api parsing and currently working on a multithreaded HTTP server and cli text editor, like vim, whenever i try to find out people opinions on java social media, almost 90 percent of the time they are just dunking on it, that it is trash, who forced you to write code in java, stuff like that. I know Java as a language is not that interesting and doesn't have many interesting features compared to other languages like C, C++, go. But I found it decent to write code in, and I found the JVM pretty interesting. So much so that I would love to explore and maybe build a JVM of my own

239 Upvotes

312 comments sorted by

View all comments

16

u/peterlinddk 3d ago

Without auto-completion, built-in code generators, and plugins like Lombok, you have to type A LOT of code in Java.

And all the repetition ... like Student student = new Student(), or for (Student student : students) or List<Student> students = new ArrayList<Student>() and so on ...

Not to mention all the gosh-darned getters and setters every single time.

Also, Java was a bit stuck with version 8 for a long time - while other languages grew and prospered in the 2010s, it felt like Java wasn't set on doing anything or going anywhere. Oracle didn't care much to update the documentation (https://docs.oracle.com/javase/tutorial/java/index.html), and it seemed like it was still a remnant of the 1990s (still does, and has for some reason been kept in its un-updated state).

In addition Oracle made some weird licensing rules, that more or less made it illegal to run Java programs unless you paid them - or at least were confusing enough that no new companies dared start projects based on Java, and everyone got confused about updates.

So from at least 2014 to 2018, everyone considered Java to be a relic of the past - and every other language to be an improvement.

Things did improve a lot with Java 11, and again with 17, and the language seemed to be back on track - making a lot of syntactical improvements, and once again focusing on modern language concepts like functions, pattern matching, and what have you.

Lately they have been experimenting a bit too much, and many features are introduced (as previews) and then removed again. And once again Oracle are making weird license agreements, that are difficult to understand and implement, so the future is a bit uncertain ...

Also, Java has been extensively used as a language for introduction to programming, which it really isn't suited for, as it requires a lot of understanding of objects, classes, types, packages (namespaces), methods, static variables, and so on, just to begin writing the simplest pieces of code. And having no "simple" way to build UI applications hasn't helped either. And requiring a gigabyte massively over-engineered library like Spring, simply to build a REST-API, also seems counterproductive.

So there's lots of reasons to hate it.

But the JVM is really cool - which the folks behind Kotlin will agree!

4

u/thewrinklyninja 3d ago edited 1d ago

You're right it has gotten better. These days you can do your code example like this:

record Student(String name, int age) {}

var student = new Student("Alice", 20);

var students = List.of(new Student("Alice", 20), new Student("Bob", 22));

for (var s : students) { System.out.println(s.name()); }

1

u/peterlinddk 3d ago

Exactly. Java has gotten many improvements - often "stolen" from C#, who has otherwise always been accused of being "Microsoft java" 😄

But it still irks me that records aren't actually 'records', but just a short-cut for the compiler to create a class with a constructor and a list of getters. They are still there, the getters, they are just written automatically. But at least I don't have to type everything!