Comment

Comment by munificent

> AsyncIterator and async generators

For what it's worth, Dart has had synchronous and asynchronous generators (including `await for` statements) for as long as its had async/await. They are neat features. I've definitely written code using synchronous generators that would be hard to manually transform into a custom Iterable implementation.

But they add a large amount of complexity to the language implementations and it turns out are very rarely used in practice. Here's a quick scrape I did of the most recently published 2,000 packages on our package manager:

    -- Style (64317 total) --
      59409 ( 92.369%): normal  =================================================
       4842 (  7.528%): async   ====
         42 (  0.065%): async*  =
         24 (  0.037%): sync*   =
Async/await is clearly pretty useful with there being one for roughly every ten normal functions. But generators and async generators are barely used at all.

Rust might be a in a different situation because efficient concurrency may be much more important in a systems language, but it's not clear to me that those same features carry their weight in Dart.

parent munificent 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton