3 ms·
The one thing I really, really hate Java for is its lack of unsigned integers (there are a lot of other minor inconveniences, like in any language, but nothing
by Slartie 5y ago
The one thing I really, really hate Java for is its lack of unsigned integers (there are a lot of other minor inconveniences, like in any language, but nothing comes close to the missing unsigned types).
This of course has to do with me frequently writing and maintaining low-level hardware and network protocol code, talking to devices on the other end that had firmware written in C and therefore expect you to be fluent in bit manipulation. But hey, all that nice software is useless if it can't eventually interface with the real world out there, so hardware will stay relevant and necessary and the accompanying close-to-the-metal code can't be optimized out of the system, hence I consider good tools for doing bit-level work an important quality in any general-purpose programming language. And besides bit-level operators that means support for unsigned integers which are needed to easily combine bit-level with classic arithmetic operations.
You can actually live without either of these in practice and still do low-level stuff, but it is very unintuitive, has poor runtime performance and leads to hard-to-read and bug-prone code.
- matsemann 5y agoWhile Java doesn't have unsigned types, it at least with java8 got functions to operate on ints as if they were unsigned. But Kotlin (also running on the jvm) got unsigned types with built in operator overloading for them, making it easy to work with. "val a = 100u" gives you an unsigned Int. If you use Java, there are few reasons not to use Kotlin. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-u-int/ https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-u-int/
- hashmash 5y ago> has poor runtime performance Are you referring to performance issues caused by lack of unsigned types? Do you have a specific example? Based on my observations, the conversions necessary for acting on signed types as if they were unsigned generates the correct machine instructions designed for unsigned types.