in reply to Re^8: Thread on Joel on software forum : "I hate Perl programmers."
in thread Thread on Joel on software forum : "I hate Perl programmers."

Your maps are cool, but take much longer to read than a for loop.
<snip>
No doubt this looks horrible to you, but anyone can see what it does in a quick scan.
Is that really objectively true, or are you just more familiar with for and less use to map? Do you think there are any legitimate uses of map (and grep, fold, etc)?

Replies are listed 'Best First'.
Re^10: Thread on Joel on software forum : "I hate Perl programmers."
by perrin (Chancellor) on Jun 17, 2005 at 15:52 UTC
    I think map and grep often lead to code that is too dense to read quickly. I do use them, when I have an operation that is short and simple enough. In particular, grep is a good "Are there any like this in the list?" operation.
      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).
        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.