Why I'm Excited about D
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Sun Apr 12 10:43:25 PDT 2015
On Thursday, 9 April 2015 at 07:00:56 UTC, Andrei Alexandrescu
wrote:
> On 4/8/15 11:45 PM, Dicebot wrote:
>> It took almost an hour to bisect all changed to trace the
>> failure to
>> this specifc line and realize that `parser.node` wasn't just
>> trivial
>> getter but method which actually advanced internal iterator to
>> next node
>> while returning current one.
>
> Thanks. The matter seems like a C++ false friend. -- Andrei
Actually, C++ had the very same issue, just the other way around.
Stuff like length() was still called like method even if trivial
and I remember resorting to naming convention to avoid wasting
time on following all symbol references. It was roughly the same
rule - no side effects or costly computations in methods named
`getXXX`, simply attached to naming convention as opposed to
calling convention.
And it was even more unpleasant than current D state of affairs.
I had much more pleasant experience of maintaining code in plain
C where separation between data and code is more forced by
language simplicity.
It is much better in languages that do support dedicated
properties because language rules can be used to express the same
notion without resorting to any conventions. And properly naming
things is unreasonably time consuming so this "by convention"
approach hardly works anyway.
The way I see situation in D is that it had an opportunity to
actually get things better than in C/C++ with @property but that
was killed in favor of seemingly "nice" syntax. Which feels
completely disproportional approach to me because saving one pair
of () per line of code is hardly comparable to being able to
better reason about the code without resorting to IDE.
Everyone who has pointed out that naming in original snippet
sucks is completely right. However, this is not really helping -
bad names will inevitably slip through here and there. Which
naturally makes me annoyed about language features that make the
issue worse instead of largely diminishing it. Mandatory () are
probably not that important on their own - but thet at least add
something to to the language, while alternative is simply syntax
sugar with no practical value.
More information about the Digitalmars-d
mailing list