On 2010-04-17, Ian Collins <ian-> wrote:
> On 04/15/10 08:41 PM, DaveB wrote:
>> The Java designers didn't think there was any need to have unsigned
>> integers. Probably because they handle the errors well and don't leave as
>> much room for undefined behavior?
>
> Now this thread has played its self out, it might be interesting to
> consider where the protagonist's views on the subject originated.
>
> I started my programming career as a hardware engineer in a team where
> we programmed all our own hardware. The company's software developers
> were all "application types" who didn't understand hardware. In that
> world of registers and buses, just about everything is a bag of bits, so
> using unsigned types is the natural way of things. I still enjoy
> embedded programming and writing drivers, so I guess I'm stuck in the
> use unsigned types mindset.
>
> I bet most of those who dislike signed types are in the "application
> types who didn't understand hardware" category.
>
I have this mentality as well when working with binary
network protocols, when signed integers must be encoded
in a specific way (big-endian two's complement, hardly
an esoteric encoding, but even so.). Everything is just
bits on a wire, and it's counter-intuitive to read bits
as negative numbers.
Right now I'm doing embedded development and the same
idea applies.
However, when I'm doing mathematical programming, and
I'm using C for some reason (either for speed or to do
numerical analysis with fewer abstractions to think
though) (otherwise Lisp or Python are far nicer to work
with), I use signed types for numbers, because in math,
numbers are signed.
So perhaps there are people who unilaterally fall into the
"application" or "hardware" categories, but I think that
most people switch freely depending on the problem domain.
--
Andrew Poelstra
http://www.wpsoftware.net/andrew