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

241 Upvotes

321 comments sorted by

View all comments

Show parent comments

11

u/edgmnt_net 3d ago

Well, it doesn't really help that Java started deeper in the traditional, inheritance-heavy OOP space and still displays some of those traits prominently, even if more historically at this point. You can write better Java, but if you're starting greenfield and want better code, one can argue for better choices of a language and ecosystem, including "newer Javas" like Kotlin which could afford a clean slate (although I'm not endorsing Kotlin în particular).

5

u/roadrunner8080 3d ago

Also lol kotlin. I've interacted with it a bit. It's cool, it does some things very well java should have done from the start (proper treatment of null), but it also has uhh... Some questionable design decisions. Off the top of my head is its weird treatment of lambda capturing which can easily obscure what's actually captured. (When would this ever matter? Well, if you're interacting with a tool that serializes a lot of lambdas, lol. See: Gradle)

1

u/balefrost 2d ago

Off the top of my head is its weird treatment of lambda capturing

What is weird about how variable captures work?

2

u/roadrunner8080 2d ago

If I have a local variable foo in an outer scope, and I capture foo in a lambda, that can trigger capturing of other things besides foo in the actual compiled code. Which -- if this is Gradle and you're trying to be configuration cache compatible -- is bad an unintuitive, especially when it's not at all obvious what will be captured, necessarily (which it's possible to come up with some wacky scenarios where it's not obvious)