Why we don't have unsigned types in the CLS

One of the highlights of my career
here at Microsoft was working on version 1 of the CLS – Common
Language Specification
. It
started as just one meeting between a few of the compiler and framework folks to
list off the framework design features that can be used in every language and it
turned into a >2 year project involving the top folks in the division. It was such fun to see Anders Hejlsberg,
Paul Vick, Peter Kukol, Jim Miller and many others arguing about what makes good
framework and programming language design.
And then, we got to take it to the 3rd party language
community where I got to see Bertrand Meyer
argue why method overloading should not be allowed in the CLS… He almost had me
convinced! "urn:schemas-microsoft-com:office:office" />

In the end, I think we came out with
a very balanced design. It gives
framework developers a wide range of tools to use while also requiring only the
minimal number of changes to most languages targeting the
runtime.

However there is one issue that
keeps coming up: Why did we not
allow unsigned types (UInt32 and the like) in the
CLS?

Well, there are really two answers
to this question. At the first
level some languages (such as VB.NET) do not offer full support for unsigned
types. For example you can’t have
unsigned literals in VB.NET…. But
to be fair that is not a completely satisfying answer because when we started
the CLS you could not subclass in VB.NET either, but we extended that language
to support what we knew people would want.
We could have done the same thing with unsigned types. But we didn’t. Why not? Well, that gets a deeper reason. In fact the same reason why early betas
of the C# language did not support unsigned types (no ushort, uint and the
like).

The general feeling among many of us
is that the vast majority of programming is done with signed types. Whenever you switch to unsigned types
you force a mental model switch (and an ugly cast). In the worst cast you build up a whole
parallel world of APIs that take unsigned types. The value of avoiding the “< 0” check
is not worth the inclusion of generics in the CLS.

As a side note the C# guys did cave
and added unsigned types to the language primarily to support interop with
unmanaged code.