3 ms·
> They save you a couple of lines or a few opening /closing braces but they make code more difficult to understand There is a massive confounding factor: popul
by jonahx 11y ago
> They save you a couple of lines or a few opening /closing braces but they make code more difficult to understand
There is a massive confounding factor: popularity, in the sense of what is familiar to the largest number of people. And this, in turn, is largely an accident of history, politics, and marketing.
Which is to say, sure, more people will understand a "for" loop written in the familiar C/Java style than a "map" one liner. But that does not mean the "for" loop is easier to understand, in the sense of expressing a concept naturally and declaratively.
- progmal1 11y agoOn the other hand having a filter construct is way nicer than having to manage the two arrays on your own. Or worse yet, when someone is trying to remove items from a list that is self resizing, it is very easy to make bugs (by not adjusting the counter in the for loop when one is removed).
- jondubois 11y agoYes, I think it boils down to popularity. As a language becomes more popular, it may be more acceptable to use more advanced constructs.