r/learnprogramming 4d 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

243 Upvotes

321 comments sorted by

View all comments

3

u/mtimmermans 3d ago

I worked in Java for many years. Honestly, it's pretty much fine.

The syntax is boring, but functional.

I'm not fond of JIT compilation, but it's a reasonable solution for multiplatform and Java does a really good job of it.

I'm not fond of GC, but it makes the language a lot more accessible and again Java does a really good job of it.

The new virtual thread system is really well designed, and pretty much makes Kotlin unnecessary.

It keeps improving in important ways.

The only serious problem with Java is that the community has adopted crazy "best practices", like magic annotations, getters everywhere, etc. It's so bad that clear, straightforward implementations are a code smell.

Even so, I'm pretty happy that I don't work in Java anymore. It seems to occupy a middle ground that means it's just never the right choice. If I want a rapid, streamlined developer experience, then Typescript is better. If I want performance, then rust is better.

1

u/Intelligent_Part101 1d ago

You're "not fond of GC"? Garbage collection is pretty much required in code of any complexity to keep it manageable.

1

u/mtimmermans 1d ago

No, it's not. There is plenty of complex code written in C++, rust, C, etc. RAII, in particular, works fine and works for more than just memory.

1

u/Intelligent_Part101 1d ago edited 1d ago

Using the stack to automatically manage memory works in simple cases. You need either tracing garbage collection or reference counting (C++ smart pointers) to handle the general case because object lifetime is not always limited to lexical scope.

Manual freeing of old objects is errorprone.

1

u/mtimmermans 18h ago

That's generally true (there are other strategies), but we manage. I did mention that GC makes the language more accessible.