A few questions

Jonathan M Davis jmdavisProg at gmx.com
Fri Jul 27 17:02:48 PDT 2012


On Saturday, July 28, 2012 01:48:00 bearophile wrote:
> Jonathan M Davis:
> > Adding something to the language doesn't buy you much more than
> > that anyway.
> 
> In the case of not-nullability, this isn't true. Integrating
> not-null in the type system allows the language to do things you
> can't do with NotNull, like:
> 
> 
> // x is a nullable class reference
> if (x == null) {
>      ...
> } else {
>      // here the type system sees x as not null.
> }

??? What does it matter if the type system knows whether a pointer is null 
unless it's trying to warn you about dereferencing null? It's not checking for 
it. If we had null checks built in, that would buy you something, but we 
don't, and we're not going to, if nothing else because Walter is completely 
against it.

> There are some other similar things you can't do with NotNull. In
> my enhancement request about not-nullability there are references
> to articles that explain the situation.
> 
> > D arguably has too many features as it is.
> 
> I don't agree, the number of features is not important. What's
> important is how clean and intelligently they are designed, how
> cleanly they interact with the other features. etc.

There's always a cost to having more features. The more there are, the more 
that you have to know, and the more that it takes to learn the language. 
Having the features be well-designed definitely helps, and for the most part, 
I'm fine with the number of features that D has, but there probably are a few 
that ideally would be dropped but can't be at this stage (as was discussed not 
all that long ago in a big thread on what language features weren't useful), 
and adding more does come at a cost. A particular feature may be worth the 
cost that it brings, but the more features that you have, the more value each 
additional feature must bring to the table.

> > And as big a deal as you seem to think that this is, the _only_
> > C-based language that I'm aware of which has non-nullable
> > references as part of the language is C#.
> 
> This is not true.

Actually, it is. I said "that I'm aware of." I didn't say that there weren't 
others, just that I didn't know of any others. But out of the mainstream C-
based languages, it's definitely rare, much as it may be becoming less rare as 
new languages come along.

> Scala, Rust, some new Java-derived languages,
> and more modern languages have not nullable references. In
> practice I think most or all new languages coming out now have
> this feature. In my opinion in few years programmers will expect
> to have it in all languages that are not too much old and that
> support some kind of nullable references.

It's not necessarily a bad feature, but I do think that it's highly overrated, 
and regardless, there's no way that it's being added to D at this point in its 
life cycle. Maybe they'll be added in D3, but I wouldn't expect to see them 
before then at the earliest. The push right now is to use the language that we 
have to get things done rather than trying to constantly add features and 
tweak existing ones. There are probably some features that we wouldn't even 
have now if we had taken that approach earlier (e.g. base two literals).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list