HACKER Q&A
📣 divs1210

Does Java need value types, now that Espresso is in the works?


A JVM in Java called Espresso is in the works under the Graal umbrella. I believe it has the potential to surpass Hotspot in terms of performance.

This paper: https://www.researchgate.net/publication/319855993_Applying_Optimizations_for_Dynamically-typed_Languages_to_Java says it can eliminate boxing etc.

Given this information, does it really make sense to add value types to the language specification?


  👤 Someone Accepted Answer ✓
The VM can only do most of its magic for fields where it can prove that they won’t get shared. That often is doable for local variables, but not for objects passed to or escaping a function.

Value types help (potentially a lot) in that they can make such objects more efficient. They also make it easier for the VM to prove fields won’t be shared (Rule: if it’s a value type, the value won’t be shared, because it can’t)