On Wednesday, November 22, 2017 00:19:51 codephantom via Digitalmars-d 
wrote:
> On Tuesday, 21 November 2017 at 20:02:06 UTC, Timon Gehr wrote:
> > I'm confident that you would be able to use null safe languages
> > properly if that is what had been available for most of your
> > career.
>
> You do realise, that all of the issues you mention can just be
> handled by coding correctly in the first place.

While I definitely don't think that it's generally very hard to avoid bugs
with null pointers/references, telling someone to code correctly in the
first place isn't very useful. Of course, it's better to do that, but people
make mistakes all the time. The real question is whether the problem is big
enough in general or bad enough when it happens to add something to the
language to mitigate it - e.g. no one should be failing to initialize
variables, but it happens sometimes, and default-initializing variables like
D does helps prevent a certain class of bugs. The programmer still needs to
make sure that they deal with initialization correctly, but the problems
that they have when they screw it up are less drastic than they are in C/C++
where variables don't get default-initialized unless they're classes with
default constructors.

Personally, I don't think that null pointer dereferencing is enough of a
problem to start insisting on non-nullable pointers or references
(especially at this point in D's development), and when it happens, it's
very clear what went wrong, so you avoid subtle problems like you'd get with
something like initializing a variable to garbage. So, I don't think that
there's enough value in having non-nullable pointers or references to add
them. In my experience, it just isn't hard to avoid problems with null. But
at the same time, I think that it's perfectly legitimate to be looking to
mitigate a source of bugs, and if you have a pointer or reference that
really never should be null, having that guaranteed by the type system
prevents mistakes, which is useful.

> Its seems to be, that you prefer to rely on the type system,
> during compilation, for safety. This is very unwise.

Any time the type system can prevent a bug, it's useful. I don't see why
that would be a problem or unwise. That's part of why many of us prefer
statically typed languages to dynamically typed languages. The compiler
catches more bugs for us that way. The question isn't whether we should use
the type system to prevent bugs. The question is which set of problems
really make sense to prevent with the type system.

- Jonathan M Davis

Reply via email to