Super-dee-duper D features

Walter Bright newshound at digitalmars.com
Mon Feb 12 01:15:42 PST 2007


kris wrote:
> Walter Bright wrote:
>> 3) Less code == more productivity, less bugs. I don't mean 
>> gratuitously less code, I mean less code in the sense that one can 
>> write directly what one means, rather than a lot of tedious bother. 
>> For example, if I want to visit each element in an array:
>>
>>     foreach(v; e)
>>     {...}
>>
>> is more direct than:
>>
>>     for (size_t i = 0; i < sizeof(e)/sizeof(e[0]); i++)
>>     { T v = e[i];
>>      ... }
>>
> 
> Yep, that's great! One of the reasons I like D so much, along with array 
> slicing.

The C++ version is even *worse* than the C one (for wordiness bother):

	for (std::vector<T>::const_iterator i = e.begin(); i != e.end(); i++)
	{  T v = *i;
	... }

I mean I know the reasons for every bit of the syntax there, and in 
isolation they make sense, but put it all together and it seems to go 
backwards.


>> 5) Lisp gets things right, according to what I've read from heavy Lisp 
>> users, by being a language that can be modified on the fly to suit the 
>> task at hand, in other words, by having a customizable language one 
>> can achieve dramatic productivity gains.
> 
> Yet, Lisp will always remain a niche language. You have to wonder why.

I'm pretty sure it's the syntax.


>> 7) A lot of companies have outlawed C++ templates, and for good 
>> reason. I believe that is not because templates are inherently bad. I 
>> think that C++ templates are a deeply flawed because they were 
>> ***never designed for the purpose to which they were put***.
> 
> Agreed. But the issue is not about how badly they're flawed. Instead, 
> it's the non-standard "language" problem. The MyDSL problem :)

I disagree with that. When you write a program using classes and 
functions, you *are* creating your own language. Classes are your custom 
types, and functions are your custom operators.


>> 8) I've never been able to create usable C++ templates. Notice that 
>> the DMD front end (in C++) doesn't use a single template. I know how 
>> they work (in intimate detail) but I still can't use them.
> 
> Same here.

But I have been able to create usable D templates <g>.


> I also look at some D templates for ages, and still can't figure out 
> just how they work. Don Clugston is known around here as the Template 
> Ninja -- the very name itself shouts out "Here Dwell Demons!" :-D

The very fact that Don's called the Template Ninja is a problem - after 
all, there is no "function ninja", no "typedef ninja", no "+ ninja". 
It's a sign that templates are still not easy enough to use.

It's like Paul Mensonidas being recognized as the "World's Leading 
Expert on the C Preprocessor." Obviously, something is seriously wrong 
with the preprocessor if there's an ecological niche for a world's 
leading expert on it. (By the way, Paul is a very nice fellow and has 
been kind enough to help me iron out several subtle bugs in the DMC++ 
preprocessor. As long as we're saddled with that preprocessor spec, I'm 
glad there is a Paul to help!)


>> 12) Take a look at what Kirk McDonald is doing with Pyd. He needs all 
>> this stuff to make it slicker than oil on ground steel. He's on the 
>> bleeding edge of stuff D needs to *make* pedestrian.
> 
> Certainly :)
> 
> What Kirk has been doing (much awesometude there) is one of those things 
> that fit into the "narrow focus" or "speciality" field that /can/ 
> benefit in some manner. But it's a black-box. When it works, nobody will 
> fuss with the insides unless they /really/ have to. That's not how most 
> commerical software is done today, regardless of all the efforts to make 
> it more like circuit-design.

Even if D fails to make metaprogramming easy for average joe coders to 
use, if it still can be used by experts to create useful black box code 
like Pyd, then it is worthwhile. After all, even though trig functions 
are very hard to write, they are easily used by joe coders as black box 
components without any problems.

(Nerd that I am, I've spent many contented hours twinking around with 
the internals of math functions to get them juuuust right <g>.)



More information about the Digitalmars-d mailing list