News for hackers. Stuff that matters.
Re:Java 17 / JDK 17: General Availability by vips7L on Tuesday September 14, 2021 @10:47AM (#28525657)
Primitive classes are being worked on in Project Valhalla.
Re:Java 17 / JDK 17: General Availability by geophile on Tuesday September 14, 2021 @10:51AM (#28525719)
I think this statement has been true since about 2014.

Structs are nice, as they allow for control over locality, to a degree that is simply not possible in Java currently. But there is a second effect, which is possibly more important: If I can move gigabytes of my data into arrays of structs, then 1) I greatly reduce memory requirements (far fewer pointers), and 2) I greatly reduce the amount of work that GC has to do.

This is such an important thing to add to Java, and it seems to be perpetually off the stove, not even on the back burner.

Re:Java 17 / JDK 17: General Availability by stickfigure on Tuesday September 14, 2021 @11:08AM (#28526003)
Alternatively: This is such a (potentially) big change, it's important to get right. I'd be disappointed if an inadequately-baked solution gets rushed in.

Another way of looking at it: This is fundamentally just a performance optimization. Java performance is already exceptional for most of Java's popular use cases (business processing). While valuable, I don't think this one feature is quite as important as you consider it.

Re:Java 17 / JDK 17: General Availability by deepsun on Tuesday September 14, 2021 @12:35PM (#28527256)
That makes sense, given the fact that they made "new Foo()" pretty lightweight anyway (for CPU, not for RAM).
Re:Java 17 / JDK 17: General Availability by vips7L on Tuesday September 14, 2021 @11:03AM (#28525921)
Some features take a long time when you have millions of users and billions of loc. Goetz recently did a State of Valhalla interview here: https://www.youtube.com/watch?v=x1_DBqJrykM
Re:Java 17 / JDK 17: General Availability by native_samples on Tuesday September 14, 2021 @01:00PM (#28527592)
It's mostly implemented in a branch. You can download a version of Java that can do this today. There's more work to do before it can be merged though, and will probably ship in incremental pieces.
Re:Java 17 / JDK 17: General Availability by nlitened on Tuesday September 14, 2021 @12:19PM (#28527039)
> If I can move gigabytes of my data into arrays of structs, then 1) I greatly reduce memory requirements (far fewer pointers), and 2) I greatly reduce the amount of work that GC has to do.

As an aside, and not to say that Valhalla is not needed (I am looking forward to it very much, along with Loom), I’ve recently learned that for many use cases (not all) when you want gigabytes of struct arrays, a bunch of equal-sized primitive arrays, one per struct field, might work even better from memory requirement and cache locality perspective.

Re:Java 17 / JDK 17: General Availability by samus on Tuesday September 14, 2021 @11:33PM (#28534946)
The semantics of primitive types should make it possible for the JVM to apply this optimization automatically. Maybe controlled via an annotation. But no clue whether it's on the roadmap.
Re:Java 17 / JDK 17: General Availability by zokier on Tuesday September 14, 2021 @10:55AM (#28525814)
> This is such an important thing to add to Java, and it seems to be perpetually off the stove, not even on the back burner.

Valhalla is being actively worked on, I'm not sure what you are implying here.

Re:Java 17 / JDK 17: General Availability by pjmlp on Tuesday September 14, 2021 @10:58AM (#28525856)
Because they don't want to do a Python move, and those compiled JARs from 2000 should keep working as much as possible on a Valhala aware JVM.
Re:Java 17 / JDK 17: General Availability by hyperpape on Tuesday September 14, 2021 @10:54AM (#28525803)
I haven't been following it incredibly closely, but I have checked in from time to time. It's a hard problem, but there's a lot of real progress (https://github.com/openjdk/valhalla-docs/blob/main/site/desi...).

I'd wager that it will ship by the next LTS, in 2024.

Re:Java 17 / JDK 17: General Availability by vips7L on Tuesday September 14, 2021 @11:15AM (#28526101)
2023 (hopefully)! They're proposing moving LTS to 2 years instead of 3.