Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Perl Books Media Programming Book Reviews

Perl Best Practices 288

honestpuck (Tony Williams) writes "I have to admit that I can bristle at books that try to preach, so Perl Best Practices was on a hiding to nothing when I came to review it. I also have to admit to being torn about the author -- after all, he is one of those poor fools who insist on living in cold, unenlightened Melbourne, while I live in vastly superior Sydney. On the other hand, how can I dislike a man who manages to place a quote that involves my favourite character, Lady Bracknell. from my favourite comic play, 'The Importance of Being Earnest,' in the first few pages of his book?" Read on for Williams' review.
Perl Best Practices
author Damian Conway
pages 492
publisher O'Reilly Media
rating 8
reviewer Tony Williams
ISBN 0596001738
summary Methods of coding to improve your Perl software


Many years ago I read a marvelous article that explained why so may early editors and word processors supported the keyboard commands of WordStar. When it's first born, a baby duck can be easily convinced that almost anything is its mother. The small bird imprints, and it takes a lot to shift its focus. "Baby Duck Syndrome" affects programmers in a number of ways, not just their choice of editor, and Conway is walking right into the middle and arguing with your imprinting on almost every page. A brave man; fortunately he has the street cred to make you at least listen.

So I carefully placed my bias and bigotry in the bottom drawer and prepared myself. I discovered a well-written, informed and engaging book that covers a number of methods (hey, 256 rules, come on Derrick, 2 ^ 8 rules can't be a coincidence!) for improving your Perl software when working in a team. That means all of us when you remember an adage a guru once told me: "Every piece of computer software, no matter how small, involves at least a team of two -- me, and me six months from now when I have to fix it." Conway puts it differently "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."

The first chapter outlines the why and where of the book. The why is to improve your code with three goals; robustness, efficiency and maintainability. The chapter finishes with a short exhortation to us to "rehabit." Don't like the word much but I applaud the aim.

Conway is far from timid. He jumps right in to the deep end of the wars, with formatting the appearance of your code. I thought the chapter was brilliantly written until he told me I shouldn't "cuddle else statements," at which point I realized what an ill-informed idiot he was. Oh, hang on. Hey, that almost makes sense. OK, that's a cogent argument for your point of view, Conway. I also have to admit that earlier you did say that your rules for this bit weren't gospel, that if you wanted a variation that was OK, just have a standard and make sure you can support it with a code prettier. Perhaps not a total idiot after all.

After successfully negotiating those shark infested waters, Conway -- obviously a man who knows no fear -- wades into naming conventions. Once again he gives coherent arguments, pointed examples and counterexamples. It all makes sense.

The book's page at O'Reilly has an example chapter and a good description, but no table of contents so here's a quick list of the headings:
  1. Best Practices
  2. Code Layout
  3. Naming Conventions
  4. Values and Expressions
  5. Variables
  6. Control Structures
  7. Documentation
  8. Built-in Functions
  9. Subroutines
  10. I/O
  11. References
  12. Regular Expressions
  13. Error Handling
  14. Command-Line Processing
  15. Objects
  16. Class Hierarchies
  17. Modules
  18. Testing and Debugging
  19. Miscellanea
Suffice to say that Conway leaves no corner of Perl uncovered, offering well-reasoned and well-explained advice on improving your Perl code.

The book is also well-written and well-edited. The order of topics covered is a sensible one, and the book is appropriately structured. It reads and feels as if you are being given the wisdom from many a hard-won battle coding and maintaining Perl code.

My one complaint is that I found it dry: you are reading through pages of argument and examples without much relief. Perhaps this book might be best digested in a number of chunks, making the effort to use the ideas from each chunk for a while before moving on to the next.

Every so often I read a book from O'Reilly that makes me fear that they are slipping, then along comes a book like Perl Best Practices, and I'm reminded that when it comes to Perl, O'Reilly authors wrote the book. Once you've rushed through Larry's book and learnt the finer points with Schwartz and Phoenix's 'Learning' titles, you may well find that this is the perfect volume to complete your Perl education. If you believe your Perl education is complete, then buy this volume and I'm sure you'll find a lesson or two for yourself.

This book is not really aimed at the occasional Perl programmer (though many of us would probably benefit from its wisdom), but at the person who is professionally programming in Perl and wants to produce better quality, more easily maintained code. For this person Perl Best Practices is a 9/10. For the rest of us, the 'rehabiting' process might be a little too arduous; personally, I'm going to pick a few of the chapters and work on those for a while, maybe naming conventions and variables. For me I'll give it an 8.


You can purchase Perl Best Practices from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Perl Best Practices

Comments Filter:
  • by koehn ( 575405 ) * on Wednesday September 14, 2005 @02:57PM (#13559545)
    Do you know why Apple pioneered Command (nee control) Z, X, C, and V for Undo, Cut, Copy, and Paste? Take a look at a QWERTY keyboard: they're the easiest keys to hit with only the left hand. Same for Command-W for close, Q for Quit, and A for select all: one handed operation, leaving the right hand free to drive the mouse.

    I grant you, left-handers and non-QWERTY keyboarders are left out in the cold, but at least there was a method to the madness.
  • by Anonymous Coward on Wednesday September 14, 2005 @03:08PM (#13559649)
    The best thing that we can do is to convince that egomaniac, Larry Wall, to stop adding junk into Perl and bloating the language into something like PL/1.

    Perl is getting to the point where you need a 2-semester college course on the subject before you can fully understand all aspects of the language.

    People love C and Perl 5.x for their simplicity. Heed the advice of the bearded, coke-bottle-thick eyeglass wearing UNIX programmers. "Keep it simple, stupid."

  • by A beautiful mind ( 821714 ) on Wednesday September 14, 2005 @03:44PM (#13559978)
    Perl didn't decrease in popularity, the others increased as people found out they can do "professional" websites in php, etc.

    RoR would be nice but it lacks the granularity of perl.
  • by SilicaiMan ( 856076 ) on Wednesday September 14, 2005 @04:18PM (#13560341)
    While it was once very big for web scripting, that arena now seems to be dominated by PHP, Ruby-on-Rails, ASP, JSP, and so forth.

    Which, IMHO, is the best thing to happen to Perl. One of the main reasons why Perl got such a bad reputation is because it is very easy to pick up. The web was (and still is) littered with a huge amount of Perl snippets written by teenage script kiddies who think that Perl and CGI are synonyms (Matt's Script Archive comes to mind).

    Personally, I have been using Perl professionally on an almost daily basis (and I'm NOT in IT or software) for over 7 years now, and have never written a single CGI program.

    Just because you don't see any web scripts written in Perl doesn't mean Perl is finished. I would actually consider that a new beginning.

  • Perl Tip of the Day (Score:2, Interesting)

    by evildogeye ( 106313 ) on Wednesday September 14, 2005 @04:45PM (#13560603) Homepage
    In 5 years of studying computer science (BS, MS) I was never formally taught Perl in a class. I learned it as the side effect of a Relational Database class. Now, 6 years later, I use Perl, ASP, and Microsoft Access on a daily basis. Not exactly the path I envisioned when I was a bright eyed 21 year old open source zealot.

    Anyway, last week my mom told me it was important for me to start giving back to society, so here is your Perl tip of the day. It took me a few months of writing awful, inefficient regular expressions to learn this doozy:

    the ? is your friend. It forces regular expressions to search for the first match, instead of the last."

    Example:

    $test = "Perl regular expression tip of the day: the ? is your friend. It forces regular expressions to search for the first match, instead of the last.";

    $test =~ /(.*?)the/;
    print $1;
    print "\n--\n";
    $test =~ /(.*)the/;
    print $1;

    C:\>perl test.pl
    Perl regular expression tip of
    --
    Perl regular expression tip of the day: the ? is your friend. It forces regular expressions to search for the first match, instead of
  • Comment removed (Score:2, Interesting)

    by account_deleted ( 4530225 ) on Wednesday September 14, 2005 @04:46PM (#13560613)
    Comment removed based on user account deletion
  • Re:how about?... (Score:3, Interesting)

    by namekuseijin ( 604504 ) on Wednesday September 14, 2005 @04:51PM (#13560658)
    ... yours truly, slashdot? Yes, perl. And Amazon.com, perl too. Show me PHP websites of this magnitude...

    and Haskell is being used to _implement_ the Perl 6 compiler for the same reason Python or Ruby interpreters are writter in C. Except, of course, Haskell is a lot higher level than C and more secure, meaning the current size of the project is just short of 4K lines. and no side-effects... ^_^
  • by ThreeDayMonk ( 673466 ) on Wednesday September 14, 2005 @06:53PM (#13561631) Homepage
    I had a theory about this, so I checked it out with this frequency table [askoxford.com] and Gnumeric.

    In the Qwerty layout, more of the most commonly-used letters are located under the left hand. Taking the limit as T, G, B, you can hit about 57% of letters by frequency. If you include occasional jumps as far as U, J, N (within reach of my relatively small hand), it's nearly 73%. Thus, it's more useful to keep the left hand on the keyboard. You can of course argue that one could move the right hand across, but the left hand starts from an advantageous position for one-handed typing.
  • An instant classic (Score:1, Interesting)

    by Anonymous Coward on Thursday September 15, 2005 @12:54AM (#13563841)
    Damian was actually gracious enough to visit our LUG last month, and hand out a few copies of Best Practices. The guy is AMAZING in person, funny, engaging and a guru of Perl and programming in general. Ive been reading the Best Practices book for the last month, and i'd say this should be on every programmers shelf, whether they use Perl or not.
    May your Rakudo never fail...

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...