I wish I could use D for everything

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Apr 30 11:02:25 PDT 2009


Steve Teale wrote:
> Jason House Wrote:
> 
>> Walter Bright Wrote:
>> 
>>> D aims to reduce project costs by reducing training time and
>>> shortening development time.
>> It really hasn't worked out that way for me with D2. Here's an
>> example from yesterday:
>> 
>> I picked up where I left off with creating a weak ref library,
>> something most other GC'd languages have as part of their standard
>> library. It probably comes as no surprise that I was getting seg
>> faults. Of course, those are supposed to be trivial to solve. I run
>> the app through gdb, and catch the crash. I can see the stack but
>> can't figure out which line the fault occurred on or what the
>> important local variables are set to.
>> 
>> I make up an incorrect theory of what could be going on and start a
>> detailed sifting through all actions of the gc. Everything was fine
>> :( I somehow notice later in the night a small usage difference
>> between my code and the GC. I fix that and try a better test to
>> ensure things work.
>> 
>> I see previously working code is now broken. I start checking code
>> and settle on std.conv being broken. Out of the 15 candidates for
>> to!(T), I overlook the one that should be used, but do spot what is
>> incorrectly being used. The code looks legit - do a conversion to a
>> string from a struct, but only if it lacks a toString function. I
>> have a to string function! I test the logic with a static assert
>> and it's wrong. Is this a compiler bug? I remember some screwy is
>> expression syntax and try that instead. Looks like the screwy
>> syntax is needed. I have always hated the is syntax because it's
>> non-intuitive. It looks like Mr. Metaprogramming (Andrei) got it
>> wrong.

By the way, I put the fixed std.conv yesterday in svn :o).

> I tend to agree about the obsessive concern in this newsgroup about
> meta-programming. In my view, the whole focus of that is to automate
> code generation that really can't be automated if you care about
> speed and efficiency because it always has to assume worst case.
> Usually, when programmers in a conventional shop do use it, they use
> it to generalize a quite narrow case - KISS.

Well I don't know. I agree that to the unwary things could look daunting 
at first, but really it all ends up in a much better place than before. 
One thing I've always admired about Walter is his willingness and 
capacity to learn new things. He once told me something that surprised 
me - that he believes many language designers don't get the power of 
templates. They would read about templates, work through a couple of 
examples, and remain unimpressed. Some languages do seem to suggest 
that. It took Walter several passes to actually "get" templates. 
Remember, at a time there were no templates in D and Walter said he'll 
never put them in, to the joy of some.

> When it aims for the wider case, it often ends up being buggy, like
> std.stdio.writefln(...) has been from time to time.

There have been quite a few bugs in the I/O functions because the 
infrastructure underneath them has gone through a few major revisions. 
As Don said, D2 is an alpha and it cannot be held to the stability 
standards of a finished product.


Andrei



More information about the Digitalmars-d mailing list