|
|
|
|
|
by SPBS
2014 days ago
|
|
In my experience `map` and `filter` are easy to grok for even for people unexperienced with FP, but `reduce` is always a headache to parse even if you know how to read it. A loop that accumulates some result is almost always better. |
|
also, if you use map + reduce, it's totally trivial to parallelise the map part and have the main thread combine the partial updates since there is no shared mutable state, e.g. Java also offers parallel streams that support this with basically zero effort. if you use loops, it can be quite hard to rewrite the code so that it is thread safe.