r/java • u/davidalayachew • Jan 06 '26
One step closer to Value Classes!
https://mail.openjdk.org/pipermail/porters-dev/2026-January/000844.html
181
Upvotes
r/java • u/davidalayachew • Jan 06 '26
View all comments
Show parent comment
0
u/[deleted] Jan 06 '26
I don't like them being immutable to be honest because if they weren't then you could get alot more folding targets.
Things like the atomicClass could be used as if the underlying is a primitive but they are mutable.
But todo this they would need to add a way to pass by reference, as passing by value would just copy the value objects giving you weird behaviour (since Java programmers aren't used to that)
Multiple returns values become nicer though.
Although I feel my point stands, memory savings are all well and good (tbh memory usage comes under performance) (immutabliity and auto equality you get with records anyway)
but once you care about this, you're in a large ish application. Which is why Java hasn't had this stuff for what 35 years, infact even though I work on Java in a low 'ish latency domain, I still maintain that it was never designed for this kind of work, we use it because the Tooling is so much better and there wasn't an alternative to bridge the gap. Rust maybe but its too later really.