Better AAs

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 11 07:27:43 PDT 2014


On Fri, Jul 11, 2014 at 02:32:31AM +0000, Tom Compton via Digitalmars-d wrote:
> On Sunday, 6 July 2014 at 22:53:56 UTC, bearophile wrote:
> 
> >Rust has not done the significant D design mistake of putting the
> >associative arrays inside the language/runtime, but D AAs are getting
> >better.
> 
> Can someone explain why having AA's builtin to the language is such a
> bad thing. I would have thought that it is a good thing because of
> greater efficiency.

IMO, it's not a bad thing to put AA's in a language in general. In fact,
when I was first considering using D, having built-in AA's in the
language was one of the big plusses for me. To this day, I still can't
get over the fact that C++ didn't even have AA's in the standard until
C++11, and the AA's in C++11 are so cumbersome to use that the last time
I tried, I almost tore out all my hair. In contrast, D's AA's, for all
their flaws, are at least *pleasant* to use without needing to reinvent
your own hash functions for every single struct, every single time.

However, due to historical reasons, the current *implementation* of AA's
in D leaves a lot to be desired. That's rather disappointing, but I
*will* say that for the most common, basic use cases of AA's, even the
current AA's in D are actually quite useful, and quite handy for simple
problems. We're all hoping the implementation could be improved, though,
so that it would also work for the not-so-simple cases, and that some
current nasty design-related bugs would finally be fixed.


T

-- 
Caffeine underflow. Brain dumped.


More information about the Digitalmars-d mailing list