r/java • • Dec 29 '21

Why everyone hates Java?

I dont understand why java is one of the most dreaded lenguages. Java got fantastics frameworks and libraries to work with it. I dont know if im skipping something or I dont work enough with Java because I like java. What do you think??

Here is the Stack Overflow Survey

268 Upvotes

367 comments sorted by

View all comments

406

u/thomascgalvin Dec 29 '21

People like to complain. Java is everywhere, which makes it a huge target.

There are some legitimate criticisms, but as the language evolves, a lot of those are being addressed. The old "Java is slow" bullshit hasn't really been true for a decade, for example, lambdas allow you to do a lot of things without the boilerplate Java is famous for, and streams and a godsend.

But the biggest reason Java gets hate is that it forces certain conventions. People think this is stifling their programming creativity or some such nonsense. Coincidentally, the people that bitch the loudest about this are also the least likely to have successfully maintained an application developed over tens of years by hundreds of people.

When I walk into a Java project, I know more or less what I'm getting into. It probably won't be the sexiest thing I've ever worked on, but it probably won't be a total clusterfuck, either.

When I'm asked to take over a Node project, though, I feel an existential dread deep in my soul. Javascript gives you enough rope to shoot yourself in the foot, and people just can't resist pulling the trigger.

79

u/nmarshall23 Dec 30 '21

Javascript gives you enough rope to shoot yourself in the foot, and people just can't resist pulling the trigger.

That's some odd rope you found there.

I'd say that some JavaScript frameworks encourage you to use enough rope to hang an entire team with.

They're just too damn clever that in 6 months no one understands the code.

193

u/[deleted] Dec 30 '21

The rope was weakly typed and got dynamically cast to a gun.

11

u/dentex_YTD Dec 30 '21

Top comment

29

u/reqdk Dec 30 '21

Because in 6 months, the trend has moved from hanging the team with a rope to stabbing everyone in the stomach with rusty knives. And I say this as someone who uses and loves (well, lovehate) JS.

8

u/dpash Dec 30 '21

I wouldn't touch a pure JavaScript project. Typescript turns that rope into candy laces.

→ More replies (1)

0

u/[deleted] Dec 30 '21

[deleted]

0

u/[deleted] Dec 30 '21

[deleted]

3

u/Persism Dec 30 '21

multiple absolute giant turds of Java projects.

Me too. The difference is these are still easy enough to refactor. In JS land it's basically just throw out and redo.

2

u/rubyrt Dec 30 '21

And even if you think about it that estimation is really hard.

5

u/ReasonableClick5403 Dec 30 '21

In my experience, java turds can be polished. A steaming hot pile of 6 year old node projects without any technical leadership? Not so much.

→ More replies (1)
→ More replies (4)

8

u/idealatry Dec 30 '21 edited Dec 31 '21

But the biggest reason Java gets hate is that it forces certain conventions. People think this is stifling their programming creativity or some such nonsense. Coincidentally, the people that bitch the loudest about this are also the least likely to have successfully maintained an application developed over tens of years by hundreds of people.

Have you ever used oldschool EJB’s? Boy, they really loved forcing their big boy, grown up conventions on everyone. And that convention was later acknowledged to result in an absolute clusterfuck of meaningless abstraction.

In fact people with actual souls started to realize that containment was a lot easier to deal with than inheritance in most cases, which kind of meant that Java’s desired OOP convention encouraged a lot of bad designs with an unmaintainable level of abstracted hierarchies.

In other words, having a convention doesn’t mean it’s a good convention.

But you know what? That’s ok. Things evolve and generally get better. And that’s true of java as well, as we’ve seen things like generics introduced (although because java envisioned such a wonderful, inescapable convention, generics are total dogshit that had to be crudely bolted onto a language where everything was an object except when it wasn’t —compared to C# or … dare I say it … Haskell). And we’ve seen some mutated, weak-ass attempt to add “function programming” (again scoffs in Haskell). All of which is better than not adding any of these things to the language, in my opinion.

What’s not ok is when we are so enamored with convention that it becomes a problem. And I find the java community, on principle, is much more conservative when it comes to introducing newer features. I’m not saying this community is a problem, but it sure as shit is annoying sometimes when you know for a fact that your language could be better but you have to wait a decade to get something C# got yesterday.

EDIT: of course the worse culprit is the need to maintain backwards compatibility, which a language like C# can ignore and add all the modern features it wants, and do it properly.

6

u/dpash Dec 30 '21

hasn't really been true for a decade

I'd say two decades. Once the hotspot JIT was introduced they performance of Java stopped being a problem.

Java does exchange memory usage for CPU performance though. Valhalla should help reduce that.

13

u/pikaynu Dec 30 '21 edited Dec 30 '21

The only gripe i had with java (older versions, 7 and below, haven't got my hands dirty with the newer releases) was the sheer amount of abstractions in their frameworks. It was hard to find a simple framework or navigate them without many years of experience. I guess that's what Go fixed. Go has very simple syntax, there aren't huge frameworks to make a project complex, imo encourages to write your own instead of importing a lib for one line of code. Rust has its own difficulties, it has way too complex syntax. It's safe but at a different cost.

And node, oh boy! It made me cry when I had to work on it. I got so frustrated that i brainwashed my team to use Go for the next one. The tooling and ecosystem were bad. We would constantly discuss on the way to implement something. We spent one full quarter of developer time to convert it to TS but that wasn't possible because only half the things were available.

Java feels a little IBMy because and that could be because big companies still have a huge chunk written in Java7 or Java8 which can't really be migrated to the newer versions.

10

u/anagrammatron Dec 30 '21

Coincidentally, the people that bitch the loudest about this are also the least likely to have successfully maintained an application developed over tens of years by hundreds of people.

Not all applications have to be maintained by hundreds of people for a decade. For many, many things Java is not the optimal solution and it's perfectly ok not to like Java. Sometimes reading Java code is like opening up a War and Peace by Tolstoy and writing it is like writing a sequel to that book. It's not everyone's cup of tea and that's ok too.

8

u/danskal Dec 30 '21

The best thing about Java is that you probably don’t have to read the code cover-to-cover. You often have a stack trace to work from, and all the objects you have are type-safe and fairly easy to reason about.

Of course you can still have stringly-typed code with lots of globals and surprise nulls. But if someone who knows what they’re doing has written it, you can pretty much rely on the IDE to tell you what’s going on.

2

u/thgkatz Dec 30 '21

Thank you!

2

u/Panzer1119 Dec 30 '21

Also I don’t understand the Boilerplate part. Like e.g. for many JavaScript Frameworks you have entire CLIs to generate templates…

1

u/ArmoredPancake Dec 30 '21

But the biggest reason Java gets hate is that it forces certain conventions. People think this is stifling their programming creativity or some such nonsense.

As Rob Pike said

They’re not capable of understanding a brilliant language but we want to use them to build good software.

Which also applies to Java.

Just because you're incapable of understanding something doesn't make it nonsense.

8

u/awesomeusername2w Dec 30 '21 edited Dec 30 '21

Oh common. Java is not inherently bad but in terms of language features it lacks quite a bit when copmared with new languages that were created specifically to address old problems.

Just to name a few: No null eafety, when many new languages can provide null safety guaranties by their type system.

Type system is not expressive enough again compared to new languages and some old ones. No sum types and such. There are sealed classes in java 17 but good luck funding a project that uses java 17. You can't do things like defining a method that accepts any object that can be serealized to json for example. You can just accept something, but whether or not it has sane serialization defined is not controlled by types. Or accept two object of the same type with sane equals. And it could help quite a lot, for example to forbid usage of classes without explicitly defined equals and hashCode as keys for a map.

Even a small service with spring boot and usual stuff concumes quite a bit of ram.

Checked exceptions is pain to use in lambdas and generally don't compose well. On the other hand you can't tell by method signature if a method will throw an unchecked exception.

Type erasure.

No languages support for async.

Large amount of boilerplate. Class with just 5 fields would need to have 10 methods of getters setters and overriden equals, hashCode, toString. And constructor in there to. While simple lombok's @Data annotation conveys just as much information in one line instead of fifty.

Simple things like 'import as' or type aliases.

5

u/couscous_ Dec 30 '21

You can't do things like defining a method that accepts any object that can be serealized to json for example.

Why don't

public <T: JsonSerializable> void foo(T t) { }

or even

public void foo(JsonSerializable t) { }

do the job?

No languages support for async.

Addressed by Loom.

Class with just 5 fields would need to have 10 methods of getters setters and overriden equals, hashCode, toString.

Addressed by records.

2

u/awesomeusername2w Dec 30 '21

Why don't public <T: JsonSerializable> void foo(T t) { }

It would be possible but usually you don't implement any interfaces for the class you do serializers/deserializers. It would be a Jackson annotation or a custom serializer referencing target class. Plus, you clutter a class with all those implementations. Eq, Json,Serealizabke, Hashable etc. With traits it ends up being much more ergonomic and you don't have to make any changes to the target class.

Loom us around the corner for quite some time already, but I'm happy to use java 11, let alone 17. Not so easy to convince everybody that we should upgrade. On the other hand, perhaps loom would be that kind of a feature that others consider worth the upgrading. In my case records wasn't that kind of a feature.

→ More replies (2)
→ More replies (3)
→ More replies (2)

-9

u/[deleted] Dec 30 '21

Fuk I switched from Java to node for work now but tbh I like it. It’s not to bad when your use to seeing it and if it’s done nicely it’s also a plus. My job got well written node code

17

u/general_dispondency Dec 30 '21

I'm curious. I had to make that switch and my life is so much harder. There are no accepted standards or conventions, I'm constantly fighting tooling, and the majority of the ecosystem is so poorly implemented and designed it's pathetic.

→ More replies (2)
→ More replies (28)