What are (were) the most difficult parts of D?

Christopher Katko ckatko at gmail.com
Thu May 12 01:06:02 UTC 2022


On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
> What are you stuck at? What was the most difficult features to 
> understand? etc.
>
> To make it more meaningful, what is your experience with other 
> languages?
>
> Ali

Every time I think I understand D, I don't.

Cool useful library functions like sumElement that magically 
don't work on static arrays.

'private' is per module, not per class, making it pretty much 
useless for preventing incorrect access and using .

completely different semantics for a class vs a struct. Is it a 
reference? Is it a value? Look up the entire declaration and have 
the entire Dlang manual open to find out.

As far as I remember, no automatic RAII support, even though it's 
insanely useful. You have to manually write scope(end) stuff 
which means any person forgetting one is now leaking memory.

Writing output in a deconstuctor (for learning) works. But then 
you accidentally combine two strings inside it and the garbage 
collecter crashes without a stack trace.

Documentation. Documentation. Documentation.

I just realized foreach copies by value by default. Maybe. 
Sometimes. When? I don't even know anymore. Because I "thought" I 
had to use foreach(ref) to be able to affect the original data 
structure (because by value means its a copy, right?). Except 
somehow everything has been working just fine, mutating the 
original structure/array from inside foreach and adding 
foreach(ref) makes no changes. Will it be faster? Maybe... who 
knows.

And I really like D! But there's lots of "WTF" moments. There's 
so much I have to Google for a single forum post with dead links 
from 2014 which is only 30% like my use-case that describes my 
error or problem.


More information about the Digitalmars-d-learn mailing list