3 ms·
Java can't even bother adding unsigned integers or integer types smaller than 32-bits. How long have we been waiting for non-boxed primitives and runtime generi
by colejohnson66 3y ago
Java can't even bother adding unsigned integers or integer types smaller than 32-bits. How long have we been waiting for non-boxed primitives and runtime generics (Valhalla)? C# has had all (except generics) since day one. New "char" types aren't happening anywhere in the near future, unfortunately.
- marginalia_nu 3y ago> integer types smaller than 32-bits ... other than short and byte, what are you missing? nibble? https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html https://docs.oracle.com/javase/tutorial/java/nutsandbolts/da...
- Delk 3y ago> or integer types smaller than 32-bits Java's got byte (8 bits) and short (16 bits)? (Still signed, though, of course.) Unless those are actually padded to 32 bits in the VM or something.
- efaref 3y ago> Unless those are actually padded to 32 bits in the VM or something. They are.
- o11c 3y agoTo be fair, they're padded in a lot of machine code contexts as well, even if you don't explicitly write `int_fast16_t`. And since Java doesn't expose pointer guts, struct padding is purely a runtime optimization concern, not a language concern.
- nwellnhof 3y agoDon't you mean `int_least16_t`?
- o11c 3y agoNo, the `least` typedefs are irrelevant aliases for the exact type these days (except supposedly some 32-bit-only DSPs exist though. But 9-bit computing has been obsolete for longer than most of us have been alive, despite talking about it). The `fast` typedefs are effectively programmer-opted-in to promotion to register size or something. But compiler optimizations often do the same thing on a per-operation level (signed overflow is UB, unsigned overflow masking can be deferred for addition/subtraction/multiplication and bitwise ops (though some can change the mask)).
- twic 3y agoThey're extended when they're locals or temporaries, but they behave like real 8- and 16- bit values in fields and array elements.
- kaba0 3y agoIn interpreted mode. They can be optimized by the JIT compiler differently though.
- patrickthebold 3y ago`char` is both unsigned and less than 32-bits.
- kaba0 3y agoIt’s quite easy to go down an already discovered path and learn from its mistakes. Also, Valhalla is said to be a 7 PhD combined-difficulty feat to pull off in a backwards compatible way, so it takes time. Java actually cares about that, instead of repeatedly pulling the plug on the whole platform like Microsoft likes to do.