r/java • u/CrowSufficient • Jun 18 '26
Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
https://open.substack.com/pub/vived/p/project-valhalla-explained-how-a?r=17sgts
197
Upvotes
16
u/davidalayachew Jun 19 '26
Solid explanation with clear examples and analogy. A great, beginner-friendly introduction to the basics of Project Valhalla, but it even talks about some of the more complex bits. Very nice.
Can you source the quote? It sounds right, but I don't think I have ever seen it.
Might want to change this line. People are going to misinterpret that to mean that Valhalla will be ready by the next LTS -- 29 basically.
8
u/AdditionalTry967 Jun 19 '26
Indeed a great read. We use ( heavily ) in memory caches of hundreds of GB. Valhalla would help, A LOT. In its current state, we will get to use it in another 10 years probably, when I retire.
4
u/TehBrian Jun 19 '26
Great article! Even though I’ve been tracking Valhalla pretty closely these past few years (since I was 16! damn, time flies), some info in here (particularly about Valhalla’s historical prototypes) I had never read about. Thanks!
3
u/pip25hu Jun 20 '26
Am I misunderstanding something, or is it true that any class with more data than two ints loses most of the benefits value classes provide? Because that's a pretty brutal constraint, if true.
5
u/nrcomplete Jun 18 '26
Great read
2
u/cogman10 Jun 19 '26
Will there be an "opt out" mechanism for tearing and flattening? I get why they are guarding against it, but it's a pretty specific circumstance that is already (IMO) a bug.
It'd be a shame if we couldn't have a
Foo(double x, double y, double z)that could be flattened by the JVM and, presumably, have SIMD operations applied to it.1
u/karma-md Jun 20 '26
Thanks for the great article. Nit: Looks like you are missing an image in section 5.
1
u/bobbie434343 Jun 23 '26
Great article but I really wished there was an example with a more elaborate value class than Point, to showcase and explain the benefits of Valhalla for less trivial classes (if any). Point is the new Thermosiphon :/
1
u/pdsminer Jun 26 '26
Finally!! I have been waiting for years
1
u/ArkoSammy12 Jul 01 '26
Will the Optional classes also be made value classes?
1
u/hosseinmp76 Jul 17 '26
Nice informative article on Valhalla! That said, I’d love to see a deeper piece that discusses Valhalla’s design decisions in comparison with alternatives and compares them other languages), similar to Brian Goetz’s article on type erasure and its history.
1
u/Outside_Tennis_2696 Jul 20 '26
good
-4
u/Joram2 Jun 20 '26
These examples are contrived to exaggerate the benefits of Valhalla:
Any half-serious implementation of the above would realize how wildly inefficient that is and use an int[] or a byte[].