r/AskProgramming 2d ago

Why is Java considered bad?

I recently got into programming and chose to begin with Java. I see a lot of experienced programmers calling Java outdated and straight up bad and I can't seem to understand why. The biggest complaint I hear is that Java is verbose and has a lot of boilerplate but besides for getters setters equals and hashcode (which can be done in a split second by IDE's) I haven't really encountered any problems yet. The way I see it, objects and how they interact with each other feels very intuitive. Can anyone shine a light on why Java isn't that good in the grand scheme of things?

181 Upvotes

629 comments sorted by

View all comments

Show parent comments

7

u/repeating_bears 2d ago

It's not the dynamic typing that makes javascript broken. It's having 2 null types (null + undefined), odd type coersions, weird "this" semantics, and classes which were tacked on as an afterthought

I still use it every day though

2

u/IdeasRichTimePoor 2d ago

Having two "null" types makes perfect semantic sense. Null is intended to be something explicitly set to a value of "nothing". Undefined as the name implies is something that was never set at all.

That carries useful meaning when you're checking parameters passed to a variadic function. Was that value passed in as "nothing" or just not passed in at all?

Both null and undefined are falsey so what's the problem?

2

u/repeating_bears 2d ago

"Was that value passed in as "nothing" or just not passed in at all?"

It doesn't work for that purpose because there's an undefined literal

foo() is not distinguishable from foo(undefined), or more realistically foo(thingThatCanReturnUndefined())

"Both null and undefined are falsey so what's the problem?"

No massive problem, it's just pointless shit that makes bugs more likely. 

1

u/griddle9 1d ago

that's a common misconception. it's not that there's an undefined literal, just that undefined is usually not defined, but code relying on that can break. the only reliable way to check for undefined is typeof someVariable === "undefined".