4 ms·
> This is a problem of optimization, not language design. It is also a problem of langage design though: JS’s HoFs are spec-defined as returning Arrays, which
by masklinn 6y ago
> This is a problem of optimization, not language design.
It is also a problem of langage design though: JS’s HoFs are spec-defined as returning Arrays, which makes fusion way more complicated.
Internal / external iteration also have different optimisation profiles e.g. Rust initially used internal iteration, switched to external because that was much more conducive to optimisations, but re-introduced an internal supplement because some combinations / patterns optimisé much better through internal iteration.
- jolux 6y agoThis is true, it does depend on how the implementation works.
- creata 6y ago> switched to external because that was much more conducive to optimisations Source? I thought conventional wisdom was that internal iteration was much easier for compilers to digest.
- masklinn 6y agohttps://mail.mozilla.org/pipermail/rust-dev/2013-June/004364.html https://mail.mozilla.org/pipermail/rust-dev/2013-June/004364... Was probably the main starting point for that change. Though I misremembered performances being the main gist of the switch, ergonomics and flexibility were. With https://www.reddit.com/r/rust/comments/5ez38g/rusts_iterators_are_inefficient_and_heres_what_we/ https://www.reddit.com/r/rust/comments/5ez38g/rusts_iterator... as the… not counterpoint but reintroduction of internal iterators. Linking to the Reddit thread rather that the article directly because lots of comments from important rust folks.