22
The Innocent Loop
(lackofimagination.org)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
This seems to me more like a complaint about JS's functional methods on arrays being eager rather than a complaint about loops. All of this is solved in languages with iterators (or async iterators for a potentially better solution).
For example, in C#,
.Wheredoes nothing immediately on enumerable types, and onIAsyncEnumerable, you can go as far as streaming/chunking results from a DB into the enumerable and filtering off the DB asynchronously just by passing the enumerable into anawait foreach. In Rust, you get the same options (though more verbose) using streams fromfutures.Edit: the rest of the article doesn't really have much to do with loops, but these are all solved problems in C#, Rust, and I assume other languages too. Even Python has iterables, and you can configure your thread pools however you want to for concurrency.
Even Java has streams and stuff. Course Java so it's kind of weird (iterators are mutable and internally iterate the collection/whatever lazily) streams are lazy and only go through all the operations, mapping, filtering ect when you collect the elements somehow (like rust). JS is wild lol