Non-nullable references, again

dsimcha dsimcha at
Tue Dec 30 21:24:23 PST 2008

> > 50% of the bugs that people run into today, coding with C# in our
> > platform, and the same is true of Java for that matter, are probably
> > null reference exceptions.

Yes, but even if this is accurate, it's misleading.  Very seldom are null
references difficult-to-find, time-consuming bugs.  Most other things in D and
other languages that are designed to prevent specific classes of bugs are designed
to prevent extremely aggravating, hard to track down bugs.

For example, GC was invented because tracking down memory leaks is a huge PITA.
Bounds checking was invented because off-by-one errors can be subtle and hard to
find.  Null reference errors, on the other hand, manifest themselves in a
predictable way (segfaults), and if you're using the safe memory model, i.e.
bounds checking, no pointers, that's about the only thing a segfault could mean.
Furthermore, null checking could be added to an implementation kind of like bounds
checking without changing the language spec.  I haven't made up my mind fully yet,
but I question whether adding lots of complexity to the language to prevent a very
easy to track down class of bugs, even if it's a common one, is justified.

More information about the Digitalmars-d mailing list