Iterators and Ranges: Comparing C++ to D to Rust

Araq rumpf_a at web.de
Tue Jun 15 10:13:07 UTC 2021


On Tuesday, 15 June 2021 at 08:22:07 UTC, Petar Kirov 
[ZombineDev] wrote:
> One of the things that I don't like about languages that I use 
> that have built-in iterators like C# and JavaScript/TypeScript 
> is that pretty much their whole ecosystems only cares about 
> input iteration and things that in D are trivially `O(1)` like 
> `array.map!foo[$/2 .. $].retro.map!bar.length` end up being 
> unexpected performance pitfalls in practice in these languages.
>

Er, performance pitfalls can be found with a profiler. Crashes 
are much harder to track down. If I have to pick between them, I 
take the performance pitfalls, as they are much easier to fix. At 
least for your outlined `.retro.map.length` snippets.

> That is not to say that I wouldn't want my libraries to be 
> fool-proof against that kind of problems, but at same time, at 
> least in my experience with D it hasn't been a big deal, so I'd 
> much rather have a powerful algorithmic API foundation than 
> prevent very useful and beautiful designs, just because they 
> can be misused.

Beauty is subjective, safety isn't.

>
>> We're slowly catching up with our support for "view types".
>
> Interesting, can you elaborate more?

Wrong forum for that.


More information about the Digitalmars-d mailing list