Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Idiomatic optimizations

by VSarkiss (Monsignor)
on Apr 29, 2002 at 17:12 UTC ( #162869=note: print w/ replies, xml ) Need Help??

in reply to Idiomatic optimizations

Beyond performance improvement, some of these transformations usually render your code "more correct" (for some suitable definition of correct). Your first point, for example, about unnecessarily quoting variables: in my experience, it's a left-over bad habit of shell programmers. It can lead to errors in strange circumstances, particularly if $foo is an object, and the stringify operator does something you didn't expect, or you didn't realize the stringified version is not the same as the object itself.

More than optimizations, I would categorize these as "Refactoring". Generally speaking, it means changing code without adding functionality, but improving it in some fashion, such as making it easier to maintain. Fowler has an entire book on the subject. Although it uses Java, some of the principles apply to other languages as well.

I recall brother chromatic was working on a refactoring editor for Perl, based on using the B back-end compilers to generate a uniform code tree, then applying these types of changes. He referred to it in his journal on use perl, but I don't know its current state (though I'm sure it'll be thoroughly tested when it's released ;-).

Comment on Re: Idiomatic optimizations
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://162869]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-08-01 07:48 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (257 votes), past polls