Modern Perl: The Book: The Draft

| 21 Comments

Update: Modern Perl: the book is out! Skip the draft and download the real thing.

Last week at YAPC I finished editing the draft of Modern Perl: The Book.

I'm pleased with how it's turned out, but I'm not yet ready to hit the "Ship it to stores!" button. In particular, I could use your help:

  • Is the material accurate?
  • Is the material effective in its explanations?
  • Are any parts confusing?
  • Is the material comprehensive?
  • Are there typos or infelicities?
  • Are the cross references appropriate?
  • Is the organization and order sensible?

You can always render the latest version of the book from a Github checkout by running perl build/tools/build_chapters.pl and perl build/tools/build_html.pl. You must install Pod::PseudoPod to build the HTML. The easiest way to install Pod::PseudoPod is to install cpanminus, either with your packaging system or with commands like:

    cd ~/bin
    wget http://xrl.us/cpanm
    chmod +x cpanm

Then run cpanm Pod::PseudoPod.

I've also uploaded the file to the drafts section of this website.

I welcome any and all feedback. You're more than welcome to contact me directly, but the easiest mechanism for me to receive feedback is in the form of bug reports, patches, and pull requests on Github. Please feel free to add your contact information to the CREDITS file if you prepare a patch, even for the simplest typo. Gratitude is important and I have much to share.

We plan to send the book to the printer sometime in August, and we'll certainly make PDFs and ePub versions available as well. For now, please don't redistribute the book; please instead distribute links to the book.

The draft chapters are:

Preface

  1. The Perl Philosophy
  2. Perl and Its Community
  3. The Perl Language
  4. Operators
  5. Functions
  6. Regular Expressions
  7. Objects
  8. Stylish Perl
  9. Writing Real Programs
  10. Perl Beyond Syntax
  11. What to Avoid
  12. What's Missing

21 Comments

Your "What's Missing" chapter is Missing.

Maybe you should add a git hook to prebuild it. I would love to start mentioning this on Twitter and Facebook, but while programmers new to Perl can probably handle the build steps, figuring out CPAN to install Pod::PseudoPod will be a barrier to entry that I expect many can't/won't cross.

You should also mention http://www.socialtext.net/perl5/index.cgi?international_perl_resources in chapter 2 "community sites". Some people prefer websites in their native language.

In the Events section, you should replace the perl_events link with http://www.theperlreview.com/community_calendar . The wiki page is outdated an the community calendar knows every event ;-)

Maybe you should also mention the efforts of the Events Group of TPF.

As a half-way step, perhaps just a quick mention of cpanm on Modern Perl's landing pages - here and Github? Installing that with curl or wget is very simple, and it's zero-conf. Even someone pretty new to Perl could have Pod::PseudoPod in under ten minutes that way.

Given that someone who is new to Perl I would expect some comments/hints to the following things:

- Where to get perl/versions

- Editor/development environment for perl

- Small start program at the beginning ala camel book

I'm not sure I like the style of eval you show in the "real programs" chapter.

Shouldn't it demonstrate as first version with error checking something along these lines: http://search.cpan.org/~elliotjs/Perl-Critic-1.108/lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm

Sorry if this comment is not helpful. I had expected Chapter I to be on a history of Perl and the explanation of the term "modern", but maybe this is deliberate, to avoid showing that Perl is old? :)

There's a typo ("Clas::MOP") in chapter 9.

Typo in Chapter 1. The word "of" should follow "example":
"The best example a linguistic shortcut in Perl is the default scalar variable, $_."

Thank you for teaching 'old Perl' along with Modern Perl. Thus, new programmers will be able to maintain old code, yet produce modern code when they write their own. Your chapter on Objects is a prime example of this.

Just sent you a pull request. ("Chocolate Perl" isn't what it is being called anymore.)

A common mistake in text processing by inexperienced Perl programmers is the use of regular expressions for trivial matches, where the regex overhead vastly exceeds the string match cost.

I would like to see the regex section begin with discussion of 'eq', 'substr' and 'index'. Encourage the use of fast and simple techniques and same complexity for when it is needed.

I love Moose ... the concept of it, at least.

All I ever see are trivial examples of it, however. Creating a Person with a first name field and a last name field is laughable, as is a bank account object with a balance.

How about a complete Sudoku solver, that reads in a text file containing the starting position. How about a GUI Sudoku game that creates a board and challenges you to solve it. How about a DNA reconstructor that reads in a file of snippets ... it can actually be snippets from any text, say a speech from Hamlet, or the text for the song Woodstock, and reassembles the original by aligning and overlapping the snipplets.

I take your point well, but those examples are awfully large for a single chapter in a 200 page book (and their explanation of the problem domain would require a lot of pages I'm not sure I can fit).

Even so, the advantages of concision and correctness from the Moose versions of even the simple examples in my text versus the hand-coded classes are striking.

I wouldn't use Perl::Dist::WiX as an example, but it DOES use Moose - and quite heavily. http://search.cpan.org/~csjewell/Perl-Dist-WiX-1.200_100/lib/Perl/Dist/WiX.pm shows the docs, at least, and you can look at the source one link away. (I need to update my website, which combines the two quite nicely, once I put 1.200_101 out - it's showing 1.200001 right now, which is before I rearranged the documentation to be cleaner.)

The second sentence of the Missing Defaults section of the What's Missing chapter is missing a period (between the words "seven" and "Sixteen"). The same sentence refers to "the previous seven" but it's not clear what that phrase refers to (design processes, versions, directions, features, or what?).

@legrady:
As one of those inexperienced (such a kind word, that..) programmers you talk about, I couldn't possibly agree more! More than once I've felt good at myself for coming up with a seemingly cool solution that made use of some complicated regex, or some new technique I had recently discovered, only to find a simpler, more elegant solution using substr, or sosuch.

It'd be great if one section of this book could put into context when using certain approaches isn't entirely beneficial.

In "What's Missing", maybe s/Three core pragmas/Three core pragmas and one core module/ as IO::Handle has its own section?

You're right. Thanks for the sanity check!

I think it would be helpful to add a header/footer with Prev, Home, and Next links to the HTML pages.

It's probably too late, but I think it would be a good addition to include something about the deployment of Perl programs (maybe as an addendum to "Writing Real Programs").

The use and deployment of dependencies is tricky for every language, but in our case this may be even more important: CPAN is one of the selling points of Perl (see the huge Moose dependency tree you'll inherit when writing OO).

Besides your test suite, what do you include in the deployment process. You supply your own perl? Add the used CPAN modules with a fixed version? You use pp/par?

Claudio

Modern Perl: The Book

cover image for Modern Perl: the book

The best Perl Programmers read Modern Perl: The Book.

sponsored by the How to Make a Smoothie guide

Categories

Pages

About this Entry

This page contains a single entry by chromatic published on June 28, 2010 3:55 PM.

The Virtuous Dilemma of Iterative Improvements was the previous entry in this blog.

When Sugar and Semantics Collide is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.


Powered by the Perl programming language

what is programming?