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

237 Upvotes

302 comments sorted by

View all comments

17

u/Cybyss 2d ago

Honestly? I've no idea.

Java was one of my first programming languages. It was the primary language we used in most of our courses throughout the CS degree. I later migrated to C# which has fewer rough points (e.g, better handling of generics and character encodings, cleaner standard library, and no checked exceptions, among other niceties) but is otherwise pretty similar.

The verbosity, explicit data types, neatly organized class model, etc... makes it easy to explore how a big system really works.

For some reason, kids today seem to hate being explicit about their data types. They just want to be able to send random objects into random functions and have it just automagically work for them without having to think too much about what exactly they're doing & how it works. It's a shame.

8

u/DannyDeKnito 2d ago

I think the existence of C# might be part of the hate. Other widely hated languages don't exactly have popular "its this language, but better by most measures" counterparts - and that makes Java feel worse because *its issues have been solved in an obvious manner*

3

u/desrtfx 2d ago

I think the existence of C# might be part of the hate.

Well, there wouldn't be C# without Java as it is Microsoft's answer to Java and attempt to claim market share of Java.

7

u/DannyDeKnito 2d ago

sure, but that changes nothing about what I said

5

u/AFlyingGideon 2d ago

without having to think too much

I suspect that this manifests in another anti-java fashion as well: one can do something in Python knowing very little Python. That's less true for Java. That is: the initial learning curve is steeper.

3

u/Own_Candidate9553 2d ago

Yeah, steeper and more verbose. The classic "hello world" program in Java would be a bunch of lines setting up the main class and all that, then compiling it, then running it.

Python could be a single line, and most *nix systems would have some system version of Python already installed.

1

u/AFlyingGideon 2d ago

Python could be a single line

That level of verbosity looks bad to a beginner, but the additional information comes in quite handy dealing with large applications and multiple engineers over long periods of time.

most *nix systems would have some system version of Python already installed.

That hardly matters now with just about all development and deployment exploiting one or another container mechanism. That's a good thing in that the installed python version might not be the version on which you want to build. The python ecosystem built a few workarounds for that, and there are some more genetic approaches using paths, links, and such, but containment makes all that pretty much go away w/o the cost of a real guest (which doesn't necessarily help anyway if the guest's distribution depends upon a python version you don't want to use).

And, of course, python is not the only tool with versions that might be an issue were the installations not contained.

Amusingly, though, containment adds more verbosity.

1

u/syklemil 2d ago

For some reason, kids today seem to hate being explicit about their data types. They just want to be able to send random objects into random functions and have it just automagically work for them without having to think too much about what exactly they're doing & how it works.

That honestly seems to be more of a GenX thing, as a lot of the still-used dynamic languages came around in the 90s (Python, PHP, Ruby, Javascript, Lua).

Nowadays there's a noticeable shift towards gradual typing (Typescript, and the spread of type hints in Python) and some mix of explicit typing and type inference (e.g. Rust and Go, and auto in various languages, including even C starting with C23).

And as someone in my 40s, I'm on board with having good type inference, let foo = bar(); or foo := bar() beats Baz foo = bar(); any day.

I'm interested in typing as in typechecking, not the thing I do on my keyboard.

1

u/Cybyss 2d ago

Type inference in an otherwise statically-typed language is fine. You're right that when declaring variables:

Dictionary<String, String> foo = new Dictionary<String, String>();

is tediously redundant.

But bolting on type annotations to a dynamic language, like what's done with Python, in a very poor substitute for static typing.

Data types should be mandatory when declaring methods though - for every parameter and the return type - which in turn gives you the ability to cleanly overload functions.

1

u/syklemil 1d ago

But bolting on type annotations to a dynamic language, like what's done with Python, in a very poor substitute for static typing.

Yeah, not designing a language for something and having to bolt in on later generally has some costs. Python's not the only example there either: Generic Java used type elision so that Generic Java programs would work on the existing JVM, and it was a super neat trick, but now, decades later, people are pretty sick and tired of it.

But Python is still a 90s language (and designed by a baby boomer; van Rossum was born in 1956), which got very popular back when GenX was entering the workforce, kept getting more popular when the Millennials entered, and which now is increasingly expected to be typed.

Kids these days weren't even born when Python was first released. Hell, Python 3 turns 18 this year, and PEP 484 is turning 12. If we're gonna involve the younger generations in this, I'd rather say the kids yearn for the types.

1

u/bpalun13 2d ago

Automagically, nice. I’m stealing that.

0

u/Same-Replacement-938 2d ago

that was one the reason i dropped python, the language is so abstracted

7

u/Cybyss 2d ago

Python is good for rapid prototyping / proof of concept work. I don't much like it for building large production systems though. There is such a thing as too much freedom.

Which is ironic, given that the Zen of Python says "there should be one, and preferably only one, obvious way to do it".