View mode: basic / threaded / horizontal-split · Log in · Help
March 20, 2012
Three Unlikely Successful Features of D
I plan to give a talk at Lang.NEXT 
(http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the 
subject above. 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.


Thanks,

Andrei
March 20, 2012
Re: Three Unlikely Successful Features of D
On 20-03-2012 20:02, Andrei Alexandrescu wrote:
> I plan to give a talk at Lang.NEXT
> (http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the
> subject above. 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.
>
>
> Thanks,
>
> Andrei

In no particular order: Lazy values, guaranteed initialization, scope 
guards, perhaps array slices, alias this / single inheritance, unittest 
blocks.

-- 
- Alex
March 20, 2012
Re: Three Unlikely Successful Features of D
On 20.03.2012 23:02, Andrei Alexandrescu wrote:
> I plan to give a talk at Lang.NEXT
> (http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the
> subject above. 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.
>
>

To throw in a few:
Scope guards, opDispatch, alias and _string_ template parameters.


-- 
Dmitry Olshansky
March 20, 2012
Re: Three Unlikely Successful Features of D
I really like the $ opperator on slices. It's something small and looks
rather unneeded. When I was dealing with java I never even wished it was
there but when I came to d and did some array manipulation I was really
glad we had that $ sign. I regularly use it and I don't seem to be the only
one feeling that way.

Maarten
March 20, 2012
Re: Three Unlikely Successful Features of D
On Tue, Mar 20, 2012 at 02:02:15PM -0500, Andrei Alexandrescu wrote:
> I plan to give a talk at Lang.NEXT
> (http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the
> subject above. 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.
[...]

By far: CTFE.

Unittest blocks, extended concept of purity, template syntax (as opposed
to C++'s ugly mess), all types have a default value (.init - makes it so
painless to write generic code!), scope guards.


T

-- 
I am a consultant. My job is to make your job redundant. -- Mr Tom
March 20, 2012
Re: Three Unlikely Successful Features of D
On 20.03.2012 20:02, Andrei Alexandrescu wrote:
> I plan to give a talk at Lang.NEXT
> (http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the
> subject above. 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.
>
>
> Thanks,
>
> Andrei

There's one huge one.

Strings as built-in types, including concatenation and slicing. This 
meant that they could be constant-folded. Together with 'static if', 
this was the basis of metaprogramming in D. Pretty much all the rest was 
a natural consequence of that foundation.
It was *completely* unexpected. When, as a D newbie, I posted some of my 
initial exploration of the language, Walter wrote "I had no idea this 
was even possible."

Probably not what you have in mind, though -- it *was* expected to be a 
success, just not to anything like this extent.

* pragma(msg) is something that's been used 100X as often as anticipated.

* Builtin properties of types, eg int.max. Doesn't sound like much of an 
improvement over a header file of constants, but it's had a huge impact. 
It really encourages you to write correct code, (I especially notice it 
for floating point, but I bet if you grep for "int.max" in D code, 
you'll get far more hits than for "MAXINT" in C code).
March 20, 2012
Re: Three Unlikely Successful Features of D
On Tuesday, 20 March 2012 at 19:50:25 UTC, Dmitry Olshansky wrote:

> To throw in a few:
> Scope guards, opDispatch, alias and _string_ template 
> parameters.

I like this list. And add, the template shorthand to!(int)() -> 
to!int() and q{} strings (though I need to remember them more 
often.
March 20, 2012
Re: Three Unlikely Successful Features of D
On 20.03.2012 21:33, Don wrote:
> On 20.03.2012 20:02, Andrei Alexandrescu wrote:
>> I plan to give a talk at Lang.NEXT
>> (http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the
>> subject above. 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.
>>
>>
>> Thanks,
>>
>> Andrei
>
> There's one huge one.
>
> Strings as built-in types, including concatenation and slicing. This
> meant that they could be constant-folded. Together with 'static if',
> this was the basis of metaprogramming in D. Pretty much all the rest was
> a natural consequence of that foundation.
> It was *completely* unexpected. When, as a D newbie, I posted some of my
> initial exploration of the language, Walter wrote "I had no idea this
> was even possible."
>
> Probably not what you have in mind, though -- it *was* expected to be a
> success, just not to anything like this extent.
>
> * pragma(msg) is something that's been used 100X as often as anticipated.

Note that because it was so successful, it was incorporated into static 
assert.

>
> * Builtin properties of types, eg int.max. Doesn't sound like much of an
> improvement over a header file of constants, but it's had a huge impact.
> It really encourages you to write correct code, (I especially notice it
> for floating point, but I bet if you grep for "int.max" in D code,
> you'll get far more hits than for "MAXINT" in C code).

And is(typeof()), even though the syntax is really horrible. Brilliant 
concept.
March 20, 2012
Re: Three Unlikely Successful Features of D
1.  Scope guards.  The need to execute some code at the end of a
scope is pervasive and has led to about a zillion workarounds
from gotos in C to RAII in C++ to try/finally in Java and C# to
with statements in Python.  D is the only language I know of that
lets the programmer specify such a simple and common intention
directly.

2.  CTFE.  There's a certain elegance to having most of the
language available at compile time and it seems like there's no
shortage of creative uses for this.

3.  Static if.  This is the most important feature for converting
template metaprogramming from an esoteric form of sorcery to a
practical, readable tool for the masses.  Most of the compile time
introspection D provides would be almost unusable without it.
March 20, 2012
Re: Three Unlikely Successful Features of D
On Tue, Mar 20, 2012 at 01:31:08PM -0700, H. S. Teoh wrote:
> On Tue, Mar 20, 2012 at 02:02:15PM -0500, Andrei Alexandrescu wrote:
> > I plan to give a talk at Lang.NEXT
> > (http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012) with the
> > subject above. 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.
> [...]
> 
> By far: CTFE.
> 
> Unittest blocks, extended concept of purity, template syntax (as opposed
> to C++'s ugly mess), all types have a default value (.init - makes it so
> painless to write generic code!), scope guards.
[...]

Oh, and I forgot static if. It's a major feature in making compile-time
stuff work like a charm.


T

-- 
Life is too short to run proprietary software. -- Bdale Garbee
« First   ‹ Prev
1 2 3 4 5
Top | Discussion index | About this forum | D home