Why is D unpopular?
Walter Bright
newshound2 at digitalmars.com
Sat Jun 11 20:03:56 UTC 2022
On 6/10/2022 12:52 PM, max haughton wrote:
> No it really is bad. Some newer areas are ok but the quality of the code is
> overall just bad, relies on enormous amounts of mutability, doesn't have a
> proper opinion about how to resolve symbols (it only has 3 passes), tries to
> make decision before properly analyzing the problem etc.
RE the symbol lookup. Before you joined us, the symbol table lookup was simple
and straightforward. But everyone complained that it was "unintuitive". Lookup
in scopes, classes, and imports, all worked exactly the same way. I spend
countless emails explaining how lookup all worked the same way. Not one person
said they understood it, it was always "it makes no sense".
So, it was changed to a 2 pass lookup. Everyone liked that, and said it was
intuitive. The 3rd pass was to enable legacy compatibility. So there you have
it, 3 passes.
It's a classic case of something that is simple and straightforward from a math
point of view is hopelessly unintuitive for humans.
As for mutability, this stems from two things:
1. using the Visitor pattern, which precludes using const and is excessively
complex (in my opinion). But as you know, Dennis and I have been gradually
replacing it with nested functions.
2. In order to support forward references, the semantic routines are lazy to a
large extent. Lazy means that when information is asked for, often it needs to
be computed if it hasn't been yet.
> The compiler is mostly reasonable semantically because D is a conventional
> language, but several key parts of the logic are either extremely old messy bits
> of code that basically cannot be easily changed or types with a very sloppy
> heritage that lead to an explosion of edge cases all over the place: Array,
> Struct, and Int32 are all considered to be the same type of thing according to
> the enum at the heart of the class that represents types,
??? isTypeArray and isTypeStruct are distinct types
> it's ad-hoc "eh just
> ship it code" that almost no one can be bothered to fix because they've either
> been scared off from working on the compiler because of aforementioned warts or
> because they've tried to divide and conquer the cleanup efforts and been told no.
Doing cleanup is hard, though you've seen many PRs from me that move in that
direction.
> Probably 40% of the bug fixes of the kind you posit are *because* of the
> frontend being unreliable.
I disagree. It's mostly because of unexpected interaction between features, or
cases nobody thought of.
BTW, I hate the front end inliner, and am trying to replace it with a far
simpler backend one. Success in that means eliminating nearly 3000 lines of ugly
code.
But I'm having some problems with the test suite, as it is failing in ways I
cannot reproduce locally. Any help in getting closer to what causes the failures
would be most helpful:
https://github.com/dlang/dmd/pull/14194
More information about the Digitalmars-d
mailing list