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

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.
  • Comment on Re^10: Thread on Joel on software forum : "I hate Perl programmers."

Replies are listed 'Best First'.
Re^11: Thread on Joel on software forum : "I hate Perl programmers."
by Anonymous Monk on Jun 17, 2005 at 16:16 UTC
    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.
        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.