4 ms·
> This can be a worthy trade-off for readability in certain cases, but in hot paths... Hot paths aren’t the common case. You should always default to the more
by baron816 7y ago
> This can be a worthy trade-off for readability in certain cases, but in hot paths...
Hot paths aren’t the common case. You should always default to the more readable syntax (map/filter) and then refactor once you’ve determined where your bottlenecks are.
Transducers are also an option to get the map/filter syntax without losing and performance, but I think most will unfortunately shy away from those.
I do agree that reduce is over used. Reducers as a pattern is really powerful (with transducers), but no one uses them right.
- _bxg1 7y ago> You should always default to the more readable syntax (map/filter) and then refactor once you’ve determined where your bottlenecks are That's exactly what I said: > in hot paths converting to the iterate-and-mutate version is one of the most common optimizations I go in and make later on > Transducers are also an option to get the map/filter syntax without losing and performance All you need are iterators. Python, Rust, Haskell, most languages support performing these functions with iterators. There are even iterator libraries for JS, if you don't mind an extra dependency. But vanilla JS does not support this.
- deleted 7y ago[deleted]