Three Unlikely Successful Features of D

pillsy pillsbury+dlist at gmail.com
Wed Mar 21 07:52:58 PDT 2012


On Tuesday, 20 March 2012 at 19:02:16 UTC, Andrei Alexandrescu 
wrote:

> There are a few features of D that turned out to be successful, 
> in spite of them being seemingly unimportant or diverging from 
> related consecrated approaches.

> What are your faves? I have a few in mind, but wouldn't want to 
> influence answers.

I know people have said all of these already, but I still want to 
vote for
them, because they're so useful, and I routinely find myself 
wishing I had
them in other languages.

     1. Array slices. These allow for a lot of gains from structure
        sharing and "flyweighting"; safe structure sharing is one 
of the
        potential big wins from GC, but in most languages with GC 
it's
        tricky to share structure that's in arrays, leading to a 
lot of
        extra space overhead for pointers and worse cache behavior
        due to excessive scattering of objects around the heap.

     2. Scope guard. At first I thought it was a neat little 
curiosity,
        but it makes it so easy to write and (more importantly) 
*read*
        error handling code that, whenever I use D, I find myself 
thinking
        about and dealing with potential failure modes that I 
would gloss
        over in another language.

     3. Template syntax. When I first saw that it used an infix 
'!' of all
        things, and that the parentheses were optional, I thought 
it was the
        dumbest syntax ever. In practice, though, it's so much 
better than
        C++'s <> disaster that it's just not funny.

A bunch of other features, like type inference, I totally 
expected to be extremely useful. The way auto lets you work with 
objects that have
unutterable types is pretty cool, though I picked that up from 
the C++11
materials I've seen. They really need the feature to make the new 
lambdas
work.

Cheers,
Pillsy


More information about the Digitalmars-d mailing list