in reply to Clever vs. Readable

There's an awful lot of TheDamian's opinion in PBP that I disagree with, but in this case he's absolutely spot on.

Clarification: What I meant by the above was that readable beats clever every time. I didn't mean to suggest that min() should be used to find the minimum of two values. I'd use the ternary operator just as BrowserUK suggested.

Replies are listed 'Best First'.
Re^2: Clever vs. Readable
by shmem (Chancellor) on Aug 09, 2008 at 23:14 UTC
    but in this case he's absolutely spot on.

    spot on? nightmare? so what does he say about the Schwartzian transform? hell of a nightmare, I guess. He's not spot on choosing a too simple construct to make an argument of readability vs. maintainability. A perl code maintainer needs a training in TIMTOWTDI, and this one is a good piece of code for that.

      The Schwarzian transform is a standard and widely used Perl idiom. This "min" example is neither of those things. You can't really compare them.

      While Perl programmers do need to understand TIMTOWTDI, they also need to understand that some of those ways are rarely appropriate. This is indeed a great example to teach them that with -- precisely because it's so unreadable. It's a great example of OWTDI that IMO few experienced programmers would seriously consider for use in production code.

      (FWIW, IIRC PBP has nothing against the ST but recommends that it be preceded by a comment identifying the construct.)