Live data from Hacker News

Java 21 makes me like Java again

wscp.dev

81–90 of 777 posts

Re: Java 21 makes me like Java again

#81

[flagged]

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.

Re: Java 21 makes me like Java again

#82

[flagged]

so, which lang would you use personally? > you still have threadpools and os threads. why this is a bad thing exactly?

Golang or Rust. If it’s a web service or microservice: Golang hands down. If it’s a desktop software or game engine, rust. If you just want to typescript your way to success, deno and vite. If you’re too introverted for Rust, Zig.

Java, whether it be spring, micronauts, jee, whatever, is wasting CPU and Memory in the cloud costing you and/or your enterprise money.

Re: Java 21 makes me like Java again

#83

Earlier quoted context omitted.

> I rarely see inheritance used in practice in java code bases. That seems absurd to me and I have a hard time understanding it, honestly.

If you type everything with interfaces in your codebase, you are much less tied to inheritance. In fact, everyone could be written to be composed. However Java doesn’t support type union so you can get into some ugly and verbose situations but the JVM doesn’t really check type so this is more a compile-time issue and could be fixed in a future Java language revision.

>However Java doesn’t support type union so you can get into some ugly and verbose situations

Isn't the "sealed interface" described in the OP blog post a type union? Or you mean anonymous unions?

Re: Java 21 makes me like Java again

#84

Earlier quoted context omitted.

This ... is how you make engineering choices?

At work, I have a different context. What is the common denominator of what people know. Personally, the “write once, run everywhere” notion of Java has been replicated with much more productive languages.

Sounds like you're talking about a pop band, not a tool.

Re: Java 21 makes me like Java again

#85

The biggest feature in Java 21 is the release of Virtual Threads: https://openjdk.org/jeps/444 For some reason, this is missing from the article. If there was any feature that would sway existing Golang developers to switch to Java, it would be this. It would perhaps also convince the haters of the reactive-style concurrency patterns.

I don't think Golang devs are waiting to switch to Java if only making a lot of threads was easier.

Honestly, its way too early. Virtual Threads will need a a "killer app" (in this case a killer framework) to pull in devs.

Re: Java 21 makes me like Java again

#86

The biggest feature in Java 21 is the release of Virtual Threads: https://openjdk.org/jeps/444 For some reason, this is missing from the article. If there was any feature that would sway existing Golang developers to switch to Java, it would be this. It would perhaps also convince the haters of the reactive-style concurrency patterns.

`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.

Re: Java 21 makes me like Java again

#87
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.

Inheritance provides "is a" relationships between classes. At a time when people would spend months designing their software upfront, building big diagrams of classes, etc, this was not so bad. You'd have a very clean system design that maps directly to your class design. The problem is when things change. A simple example - you build a classification of all life and it is built upon the idea that everything "is a" p…

This problem is partly a type system limitation however.

In a more flexible type system with union types and other magical features, your example problem would be less of an issue.

However Java has an extremely limited type system so there is no middle ground between composition and inheritance. Once you choose one way, there is no “middle step” to migrate over.

Re: Java 21 makes me like Java again

#88

Earlier quoted context omitted.

so, which lang would you use personally? > you still have threadpools and os threads. why this is a bad thing exactly?

Golang or Rust. If it’s a web service or microservice: Golang hands down. If it’s a desktop software or game engine, rust. If you just want to typescript your way to success, deno and vite. If you’re too introverted for Rust, Zig. Java, whether it be spring, micronauts, jee, whatever, is wasting CPU and Memory in the cloud costing you and/or your enterprise money.

> Golang

golang is probably a good contender for business logic code where Java is widely used, but I feel ecosystem (libs, integrations) is not comparable to Java, so you take some risks while choosing golang.

Re: Java 21 makes me like Java again

#89

The biggest feature in Java 21 is the release of Virtual Threads: https://openjdk.org/jeps/444 For some reason, this is missing from the article. If there was any feature that would sway existing Golang developers to switch to Java, it would be this. It would perhaps also convince the haters of the reactive-style concurrency patterns.

`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”

Re: Java 21 makes me like Java again

#90
post #29

Earlier quoted context omitted.

Sorry, what? Is not java toghether with Ruby maybe the most hardcore OOP enthusiasts that uses inheritance for "most stuff". Has the java culture move so far the last decade ?

Effective Java, written by Joshua Bloch, and first published in 2001, had a very influential section called Favor composition over inheritance: https://books.google.co.nz/books?id=Ra9QAAAAMAAJ&q=inheritan... Why do you think DI is so prevalent in Java codebases? It's a great way of simplifying composition.

>had a very influential section called Favor composition over inheritance

The GoF book (Design Patterns) had the same, somewhere early, like in the Introduction, in 1994:

https://en.m.wikipedia.org/wiki/Design_Patterns

Post reply on HN