Send to Printer

development

Why simplicity is better

November 9, 2005 7:45:13.213

Ted Neward describes Null in .NET:

To lay down the background first: dealing with NULLs has always been somewhat problematic; the most obvious example of this is the mapping between relational databases, where even an INTEGER column can either have a value, or be empty, or be NULL, each of those being separate and distinct states. Trying to map NULL integer column values to integer values in the language has always been difficult in Java. C++, and C#, since primitive types / value types generally don't support null values, and Anders (among others) decided that it was time to try and integrate nullability more deeply into the language. The .NET team saw an opportunity to support nullability by creating a generic/templatized type to represent the possibility of nullability, and the C# language team took it further to try and make nullability feel "more at home" within the language. It was a bold, if at first seemingly-trivial, step.

As opposed to, say, going with a real object model, and then having null be - wait for it - just an instance of a class. Like, say, UndefinedObject. Nah, that wouldn't be nuanced enough. Or something...

Bonus link - more complexity masquerading as simplicity here.

Comments

"whole" objects

[Lex Spoon] November 9, 2005 12:10:13.099

Yeah, who says a "simple" little integer needs to be a "whole" object?

Saying that int's are not objects is a classic example of premature optimization -- and an extreme one, too, considering that it's baked right into the language. If you use Java or C++, then you are stuck with the language designer's shortsighted decision.

 Share Tweet This