Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

111–120 of 777 posts

Re: Java 21 makes me like Java again

#111
post #73

[flagged]

Having worked extensively in Java, Node, and Python, I’ll take the JVM ecosystem absolutely any day of the week. Me and my catheter will be over here delivering actual software while you figure out how React 32 broke your transcompiler.

Except I’m over here serving 10x the traffic with 10x less cloud spend on CPU and Memory for hosts.

Re: Java 21 makes me like Java again

#112
post #86

Earlier quoted context omitted.

`Executor.newVirtualThreadPerTaskExecutor` versus `go` really gets to the heart of why I think that Go developers aren't going to be switching. edit: Sorry, it's actually: try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { executor.submit(...) ) instead of `go`

So basically executor.submit(). And you still have a language that is significantly less verbose than go, objectively.

Yes, if you ignore more than half of the code it's quite concise.

Re: Java 21 makes me like Java again

#113

Earlier quoted context omitted.

There is nothing wrong with inheritance. But sure, there is usually something wrong with deep inheritance or using it, where better solutions exist.

No, there's a lot wrong with inheritance. It leads to all sorts of issues and while theoretically one can keep the tree 1 level deep, in practice it's too tempting to expand the hierarchy. This is one of Java's big issues. The other is reference equality as a default, pretty horrible. Records help but records are also limited in when they can be used.

You don't like code reuse?

Re: Java 21 makes me like Java again

#114
post #73

Earlier quoted context omitted.

Having worked extensively in Java, Node, and Python, I’ll take the JVM ecosystem absolutely any day of the week. Me and my catheter will be over here delivering actual software while you figure out how React 32 broke your transcompiler.

Except I’m over here serving 10x the traffic with 10x less cloud spend on CPU and Memory for hosts.

In what language would that marvel be? I give you the less memory....

Re: Java 21 makes me like Java again

#115
post #105

The problems with Java can't be fixed by adding new things, you can't undo decades of ecosystem development, training, and ideology built on top of the idea that inheritance is really good idea and belongs everywhere. edit: I will say that as a Java developer I am grateful every day for the improvements to the language. Java is a very impressive language and I have a lot of respect for the people working on it.

Prefer composition over inheritance has been a common mantra for at least a decade, if not more. Maybe you should undergo the last decade of development and training. There will always be shitty devs, and since java is one of the biggest languages, it definitely has more than some ultra niche academic language no one uses. I don't think it is the fault of the language though, or if that somehow were a reason to choos…

Just because everyone has been saying "composition over inheritance" doesn't mean that that's how things get done. Jump into any Java codebase and you're 99% likely to see inheritance used as one of the primary abstraction mechanisms.

> Should a decent BMW driver sell their car, because plenty assholes buy that car also?

A better analogy would be "Should you drive on the street where all of the shitty drivers do donuts and street races?"

Re: Java 21 makes me like Java again

#116
post #40

Earlier quoted context omitted.

Please ELI5 what is wrong with inheritance and/or how Java have it wrong. Do we need to go back to a new object oriented undegraduate course? Genuinely asking.

With compositions A uses B but B can never use A. With inheritance Child can use the Parent, but Parent will also call the Child (virtual methods) which in turn can call the Parent again etc.., so the code can become difficult to follow. It can become very complicated with multiple inheritance and multiple levels.

I've certainly done that in the past, but not since I changed jobs ... 7 years ago. Probably not for several years before then.

Re: Java 21 makes me like Java again

#117
post #113

Earlier quoted context omitted.

No, there's a lot wrong with inheritance. It leads to all sorts of issues and while theoretically one can keep the tree 1 level deep, in practice it's too tempting to expand the hierarchy. This is one of Java's big issues. The other is reference equality as a default, pretty horrible. Records help but records are also limited in when they can be used.

You don't like code reuse?

That question seems blatantly disingenuous.

Re: Java 21 makes me like Java again

#118
post #81

Earlier quoted context omitted.

Exactly what is enterprise? I think Java has a role to play in most professional settings, even if the company is quite small. It is not a sports car but I see it more as a truck or a cargo ship. Vehicles that underpin the world economy, but that only few think of as fun or exciting. Not pretty or nice to look at, but reliable work horses.

It is for sure the wagoneer when it comes to getting things done in the enterprise, if it was 2005. It’s not a sports car, it’s not a dune buggy, it’s not even pretty in its wood paneling and drab paint scheme. But it got your family to Wisconsin for the holidays. In 2023, we have better options.

Such as...?

Re: Java 21 makes me like Java again

#119
post #113

Earlier quoted context omitted.

No, there's a lot wrong with inheritance. It leads to all sorts of issues and while theoretically one can keep the tree 1 level deep, in practice it's too tempting to expand the hierarchy. This is one of Java's big issues. The other is reference equality as a default, pretty horrible. Records help but records are also limited in when they can be used.

You don't like code reuse?

Love it, and love using plain ol' functions for it

Re: Java 21 makes me like Java again

#120

Earlier quoted context omitted.

`Executor.newVirtualThreadPerTaskExecutor` versus `go` really gets to the heart of why I think that Go developers aren't going to be switching. edit: Sorry, it's actually: try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { executor.submit(...) ) instead of `go`

Wrap it in class Go { static void go(…) } and it will look better with “import static”

I assume `Go` would have to be Closeable and you'd still need the try-with-resources, right?
Post reply on HN