By bloid
via in.relation.to
Published: Nov 16 2007 / 11:36
While there are many things I like about the Java language, the lack of unsigned types has always bothered me.
According to Gosling, they were too complicated:
Quiz any C developer about unsigned, and pretty soon you discover that almost no C developers actually understand what goes on with unsigned, what unsigned arithmetic is. Things like that made C complex.
Ironically this kind of hand-holding tends to introduce other complexities that are often more difficult to deal with than the original solution. In this particular case, leaving out unsigned types doesn't stop the need to work with unsigned data. Instead, it forces the developer to work around the language limitation in various unusual ways.
Comments
daniel replied ago:
I disagree, but a thought-provoking article.
kdavies replied ago:
I agree with the article, there has been many times I wish there were unsigned types, and have had to do weird work arounds.
bloid replied ago:
yeah, reading legacy file formats from the spec document makes you shudder when you read "uint" ;-)
jtheory replied ago:
I doubt the proposed solution is feasible, but I agree that working with unsigned bytes in Java is a headache. I ran into it writing a Java classfile reader, of all things... it's painful working with Java's own bytecode in Java, because... yeah, those bytes.
Does anyone know of good OSS libraries to facilitate working with unsigned bytes? I have looked terribly hard, but I haven't run across anything in Apache commons, etc..
Voters For This Link (16)
Voters Against This Link (1)