Java has support for unsigned integers since java 8... its just in java's fashion, they are methods bolted onto the standard Integer class instead of proper unsigned primitives.
I have written a lot of code that would benefit from primitive unsigned ints...and while it is a little more work to do it java's way, it's definitely not a horrid mess
Eh, if you use the API, I just go up a size and use bitwise operators, the JIT is fast enough that it's usually not a problem. Definitely not 100x slower
We're not comparing to C, we're comparing to a theoretical java that has primitive unsigned ints since that was your original complaint. Ofc C is faster, java is faster to write than C though. I write both, there are different tools for different jobs
Eh. I rarely use unsigned integers, and using 4 extra bytes for large numbers is nothing when the jvm is already chugging RAM... So lacking uint isnt that big deal. Though, why is a byte signed...? That is beyond me.
Iirc, the decision was made for performance reasons and reducing programmer confusion. Even in the .net world, unsigned ints are against the CLS spec and using them in c# has compiler warnings. Really the only reason to care about unsigned ints is reducing memory footprint...which case Java shouldnt be your choice lang to begin with.
I understand that reasoning but the dude literally forgot to add uints. Which is funny I think. Then they never fixed it (this math library stuff is just a weird band aid).
Today it is less important I guess, but back then it sure wasn't. I also don't really care what C# specs say, that has nothing to do with the story IMO.
16 Comments
Valmond@lemmy.dbzer0.com · -6 pts · 4d
Are there unsigned integers on the inside or are they still lacking?
Lol
piccolo@sh.itjust.works · 4 pts · 4d
Java has support for unsigned integers since java 8... its just in java's fashion, they are methods bolted onto the standard Integer class instead of proper unsigned primitives.
Valmond@lemmy.dbzer0.com · -1 pts · 4d
Yeah so it doesn't. That's just a horrid mess.
If you'd know your history, uints were forgotten in the first version, and never added.
Scoopta@programming.dev · 1 pts · 4d
I have written a lot of code that would benefit from primitive unsigned ints...and while it is a little more work to do it java's way, it's definitely not a horrid mess
Valmond@lemmy.dbzer0.com · 2 pts · 3d
Just 100 times slower lol
Scoopta@programming.dev · 1 pts · 3d
Eh, if you use the API, I just go up a size and use bitwise operators, the JIT is fast enough that it's usually not a problem. Definitely not 100x slower
Valmond@lemmy.dbzer0.com · 1 pts · 2d
If you do C bitwise operations on big chunks of data (like encryption) Java is probably more than 1000 times slower 😁
Scoopta@programming.dev · 1 pts · 2d
We're not comparing to C, we're comparing to a theoretical java that has primitive unsigned ints since that was your original complaint. Ofc C is faster, java is faster to write than C though. I write both, there are different tools for different jobs
piccolo@sh.itjust.works · 1 pts · 4d
Eh. I rarely use unsigned integers, and using 4 extra bytes for large numbers is nothing when the jvm is already chugging RAM... So lacking uint isnt that big deal. Though, why is a byte signed...? That is beyond me.
Valmond@lemmy.dbzer0.com · 1 pts · 3d
So you don't need it means it's okay a major feature is just forgotten for 20 years? I'm not even criticising you, I'm criticising the language lol.
piccolo@sh.itjust.works · 2 pts · 3d
Iirc, the decision was made for performance reasons and reducing programmer confusion. Even in the .net world, unsigned ints are against the CLS spec and using them in c# has compiler warnings. Really the only reason to care about unsigned ints is reducing memory footprint...which case Java shouldnt be your choice lang to begin with.
Valmond@lemmy.dbzer0.com · 1 pts · 2d
I understand that reasoning but the dude literally forgot to add uints. Which is funny I think. Then they never fixed it (this math library stuff is just a weird band aid).
Today it is less important I guess, but back then it sure wasn't. I also don't really care what C# specs say, that has nothing to do with the story IMO.