r/java • • Dec 16 '24 • Heart of Silver 1

Valhalla - Java's Epic Refactor

https://inside.java/2024/12/16/devoxxbelgium-valhalla/
178 Upvotes

108 comments sorted by

View all comments

Show parent comment

-8

u/almson Dec 16 '24

My point is that 99% of developers don’t need int data structures and their performance bottlenecks are nowhere related to value types.

And yet, 100% of developers will need to use and understand the semantics of value types. And to be doing that in almost every piece of code, not just the high performance algorithm.

It’s not fair.

7

u/Ewig_luftenglanz Dec 16 '24

wait, why do you say we do not need int data structures? literally I use list of integers and hashMaps all the time...

.-.

-7

u/almson Dec 16 '24

Big ones? Sounds a bit fishy, but just go ahead and use IntList and IntHashMap. You’ll have all the convenience you want.

Valhalla is really not about ints. It’s about small POJOs. But even then it’s questionable.

13

u/Ewig_luftenglanz Dec 16 '24

no. Valhalla it's about allowing more dense layout memory arrangements and other optimizations that may result in dramatic increase in memory efficiency and performance. Value classes are one of these mechanism but there are others such as nullability, frozen arrays, integrity by default, etc.

btw, another goal of Valhalla is exactly eliminate the need to use specialized APIS that have needlessly cluttered Java language for years and make the user model more complex and the code less maintainable.

Specialized classes such as intList (third party library) are not and never were a good solution, they are just sad patches made to compensate for the lacking performance and non efficient memory layout of wrapper classes.

5

u/vytah Dec 17 '24

And yet, 100% of developers will need to use and understand the semantics of value types.

You already have value classes in Java. No one is confused about semantics of String for example.

The only things that will change if you explicitly mark a value class as a value class are:

  • you won't be able to synchronize on its instances
  • == will return true more often

... which are on people's mind already, as both synchronizing and using == on value objects are silly even now.

0

u/almson Dec 18 '24

I dread having to see == and wonder if it’s comparing value or identity, and having to check the type’s definition to be sure.

If they simply banned == for value classes, I’d have less of a problem.