[Pdx-pm] Readable code
randall at sonofhans.net
Mon Jan 10 23:35:39 PST 2005
On Jan 10, 2005, at 10:55 PM, James marks wrote:
> I'd be very interested in your thoughts and suggestions regarding
> terse code, readable code, verbose code, etc...
josh is fond of damian conway's saying, "any ten lines of perl can be
reduced to one line." you can write some pretty terse code in perl,
and it's easy to see the attraction. like any tool, when you get to
know it better you can use it more efficiently. expressing a
relatively complex thought in 30 characters of seeming line noise can
feel pretty powerful.
and, as you say, be impossible to read. i suggest writing perl the
same way you'd write anything else: for your audience. sometimes your
code will be more verbose, but that isn't always bad. you don't read
hegel to your toddler.
if you're writing a system maintenance script on contract, write it
cleanly and simply, since you don't know who will have to modify it (a)
under pressure, and (b) with limited perl knowledge. if you're writing
for a more specialized audience or where your own time optimization is
of the utmost importance, pull out the stops and be idiomatic.
More information about the Pdx-pm-list