4 ms·
Personally, I find functional styles to be easier to understand. Transforming data by composing functions is easier for me to understand because each step gene
by cle 11y ago
Personally, I find functional styles to be easier to understand. Transforming data by composing functions is easier for me to understand because each step generally stands by itself, with no state to keep track of across steps. This generally leads to less buggy code.
Also, I find that manually managing control flow leads to a lot of bugs. If I have tricky for-loop with lots of continues and breaks, the complexity leads to subtle bugs. I try to avoid those features as much as possible, deferring control flow to functional composition. In general, there are less edge cases to manage with a functional style (control flow, null collections, etc.).
There are definitely performance reasons to use traditional for-loops, but the vast majority of the time it's appropriate to sacrifice performance for stability and readability.