It is the year 2020: why should I use / learn D?

Eugene Wissner belka at caraus.de
Wed Nov 14 16:09:32 UTC 2018


On Wednesday, 14 November 2018 at 15:49:48 UTC, jmh530 wrote:
> On Wednesday, 14 November 2018 at 15:33:49 UTC, rikki 
> cattermole wrote:
>> [snip]
>>
>> Really butchered. From what I can see they never mentioned D 
>> in any of the documents (kinda glad tbh). Those documents even 
>> question what it should be doing...
>>
>
> I recall D being briefly mentioned in the Range specification. 
> They rejected D's approach because they wanted to build on 
> existing iterator-based code.

No, it wasn't the reason. Some algorithms cannot be implemented 
with ranges as efficient as with iterators.

"In other words, by converting the is_word_boundary from 
iterators to D-style ranges, the algorithm goes from O(1) to 
O(N). From this we draw the following conclusion: D’s choice of 
algorithmic basis operations is inherently less efficient than 
C++’s."

C++ iterators are more flexible. I think of things like rotate 
and bringToFront - in C++ you need begin, end and middle 
iterators. In D you can't have something like a "middle", you 
have to pass two independent ranges. But since most algorithms 
require begin and end iterators I like D ranges because they 
aren't that verbose. But D ranges aren't always nicer, for 
example SList.insertAfter requires a hack with accepting 
Take!Range instead of just Range.


More information about the Digitalmars-d mailing list