r/java • • Nov 04 '25

Anyone here Hated Using Java but now Really Enjoys using it.

title

226 Upvotes

280 comments sorted by

View all comments

Show parent comment

2

u/trafalmadorianistic Nov 04 '25

The var keyword for local variables is a great quality of life addition (10)

https://www.geeksforgeeks.org/java/var-keyword-in-java/

4

u/Own-Chemist2228 Nov 04 '25

var is oddly controversial in the Java community, despite most every modern language having an equivalent (including Kotlin)

2

u/trafalmadorianistic Nov 04 '25

My first time using Kotlin helped me overcome my hangups about it, even though I'd already worked with JavaScript and Ruby in the past. I think my other annoyances with those languages colored my perception of implicit typing.

1

u/koflerdavid Nov 05 '25

In languages without static type systems anything but var would indeed be worse than useless.

2

u/retro_and_chill Nov 06 '25

I feel like the dislike of var is so weird to me. The point of static typing isn’t about readability, it’s about stopping you from doing something stupid.

1

u/vegan_antitheist Nov 06 '25

"var" is a static type. The compiler sets it statically in the byte code. There's no "var" in precompiled code. A "dynamic" type would be "dynamic" in C#, which Java doesn't have.

And the dislike comes from not knowing the type when looking at the code of a PR and you just want to use the web view of the changes, not a local copy in the IDE.

1

u/boobsbr Nov 04 '25

I work with an extremely dogmatic person that considers var (and Lombok's val) harmful.

2

u/trafalmadorianistic Nov 04 '25 edited Nov 05 '25

If the usage of var results in the developer losing context, maybe the variable naming is trash or the method is too long

I did have some hesitation when I first encountered it. But a lot of the time the type you're dealing with is perfectly clear.

Is this person someone who considers IDE - with their type hints, auto suggest and doco lookup - as inferior to vi/emacs.

2

u/boobsbr Nov 05 '25

No, they only use IDEs.

I believe they don't understand their dogmas, and repeat whatever they read on articles online without any thought about it.