[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Eliminating whitespace does not usefully shorten code



Luc St-Louis <lucs@CAM.ORG> writes:
> There is value in being able to say "This code snippet is shorter than
> that code snippet" because it usually indicates that a more appropriate or
> more elegant construct has been used.
> 
> Unfortunately, this `shortening' is too often pushed to the excess of
> removing all non-strictly necessary whitespace.  But, I believe,
> mostprogrammersfindcodewithwhitespaceeasiertoread.
> 
> So, all other things being equal, please use whitespace liberally when
> writing your code. And if you insist on comparing code snippets based
> on their respective exact lengths, then just subtract from the count
> the amount of `unnecessary' whitespace they contain.

Given that I recently wrote a brief article to FWP suggesting a shorter
version of a one-liner by John Porter, and counting characters in his
version and mine, I have to assume that these comments are directed at least
partially at me.

I entirely agree that production code is best optimized for maintainability,
and in almost all situations I do so as a matter of course.  Sometimes this
has the same effect as optimizing for shorter code, but not always.

But I would also point out that there are situations where there is value in
being obscure -- and this is precisely the point of, say, the Obfuscated
Perl contest.  Now, I don't claim to be able to write JAPHs or Obfuscated
Perl entries.  But I do enjoy trying to decode them -- it's a challenging
puzzle.  I claim that the same sort of fun can be found in searching for
another Way To Do It, especially if unusual constraints (such as low
character count) are placed on the result of the search.  And after all,
last time I checked, this mailing list was for Fun With Perl.

-- 
Aaron Crane   <aaron.crane@pobox.com>   <URL:http://pobox.com/~aaronc/>

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe