In 2015 @sjrd and @densh drafted a SIP for the addition of 4 “primitive” types to the standart library for representing unsigned integers: UByte
, UShort
, UInt
and ULong
.
However, based on the following quoted requirement, the SIP was rejected because the performance of unsigned AnyVal
s was inferior to native built-in signed JVM primitives.
Since they will inevitably be “branded” as primitive data types, unsigned integer types should be as efficient as signed integer types.
Despite it was rejected i have some questions about some SIP quotes but in the context of Valhalla language model. Answer if you want.
Topics:
Scala has custom-made
AnyVal
s and other Object-Oriented abstractions on top of primitive types that can allow for additional, zero-overhead “primitive” types
- Is Valhalla project trying to achieve something like Scala´s AnyVal (inlined classes with zero overhead), if that is the case does Scala benefits at all?
Java cannot decently add new primitive types for compatibility reasons
- Valhalla also suffers from Boxing/Unboxing of primitives, does that make the quote above still stand true?
- Does the JEP 402: Classes for the Basic Primitives (Preview) improves it at all?
arrays of unsigned integer types will suffer from the same performance penalty as arrays of user-defined
AnyVal
s, because the elements will be boxed.
- Is there any hope for this ever to be addressed at the JVM level?
Pertinent references:
JEP draft: Value Objects (Preview)
JEP 402: Classes for the Basic Primitives (Preview)
JEP 401: Primitive Classes (Preview)