Comment by NikkiA
7 years ago
You'd probably be surprised how many GC'ed languages actually avoid the whole tagged/boxed variable thing in pursuit of the performance benefits. ocaml for example is limited to 30bit ints for this reason, the haskell standard only guarantees 30bits from the 'Int' implementation for this reason.
As I said further down this thread though, it's a 'speed' thing, not memory storage thing, the common belief is that boxing is slow, because it was slow in java, but in reality boxing is a) a mostly acceptable trade-off that only loses out in extreme cache-limited situations, and b) something that could be optimised away anyway.
My comment concerned heap-allocated user-defined types, not primitive types like int. Also, these techniques of tagging primitive types predate Java, so whatever convinced people that they are needed, Java wasn't it. (Though things change, so yes, it's a possibility that they are no longer needed. Do you have benchmarks?)
I agree that a lot of boxing can be optimized away, but often it also can't.