Here's a hypothetical for you. Let's say we have a two working implementations of a chunk of code. One incarnation (code "A") uses map, grep, and other higher order functions, and is 25 lines long. The other piece of code ("B") uses for and while loops and is 75 lines long. We've also done some studies and found the following correlations between programmer experience and time to grok each example...
TIME TO UNDERSTAND (minutes)
Experience | Code "A" | Code "B"
Level | (maps) | (fors)
------------+----------+-----------
Expert | 10 | 20
Average | 50 | 35
Entry Level | 120 | 60
...which coding style would you prefer? (Feel free to make up your own example to show different time breakpoints/code density levels/costs of programmers). | [reply] [d/l] |
Most programmers tend to be overly optimistic about how expert they are and about how long it will take them to understand code that they haven't looked at in months.
| [reply] |
But I'll make the contention that anyone who becomes familiar with how "map" works, will find code using that operator easier to come back to, as opposed to coming back to code which uses willy-nilly "for" loops. I see it similar to GOTO's. Inexperienced programmers have no problem using them. Better programers though, appreciate the invariants that come with using higher level constructs. Besides, I wouldn't trust a programmer that knows perfectly well how "map" works, but decides that they prefer to reinvent their own list traversal schemes.
| [reply] |