The Perl community on LinkedIn is fascinating. It’s a great way to see how Perl is perceived and used outside of the echo chamber. And that’s a real eye-opener.
Here’s an example. Every few weeks (it seems) someone asks for advice on Perl books.At that point, a few people will jump in with sensible suggestions. But for every reasonable suggestion, you’ll get three or four people suggesting something from this list:
- Something horribly out of date. A lot of publishers stopped updating their Perl books about ten years ago. The most recent version of Perl Black Book that I can find is from 2001. Teach Yourself Perl in 21 Days was last updated in 2002. Perl By Example dates from 2007. I haven’t read any of these books, so I can’t comment on their quality, but I’d be really wary of suggesting that someone learns Perl from a book that is so out of date. Before the days of Amazon, these books would quietly disappear from bookshops, but now they always seem to be available.
- Something out of date, but that used to be great. There are plenty of books that I would have recommended when they were current, but that I wouldn’t really want to recommend now. A lot of these are O’Reilly books that haven’t been updated recently – Advanced Perl Programming and The Perl Cookbook, for example. I’m sure there’s lots of good stuff in those books. But I really wouldn’t want anyone to read them if they didn’t already have enough experience to update the Perl to current best practices. I sometimes recommend these books myself, but only in specific circumstances. Whenever I run a course on OO Perl I mention Damian’s book. But I also point out that there have been a lot of advances in the area since the book was published. And, I have to confess, my own Data Munging with Perl fits firmly in this category.
- Something of dubious provenance. Most of these discussions will, at some point, attract a link to some dubious web site in Eastern Europe that contains the full text of O’Reilly’s various CD bookshelves. I know that these sites exist and I know that there’s nothing that O’Reilly can do about them, But I’d rather not see them mentioned on a professional site like LinkedIn. And quite apart from the copyright issues, there’s the fact that most of the books on these sites fall firmly into the first category above. They’re all over ten years old.
- Some great tutorial on the internet. I’ve talked about the problems of old and dodgy tutorials before. And things definitely seem to be looking up. We are getting more good tutorials out there. But people still insist on sharing links to the tutorial that they learned from. Even if it’s appalling.
In a recent discussion, someone said (and I’m paraphrasing) “just go to Amazon and look for the highest rated books”. I think there are two problems with that:
- The people who are rating beginner’s programming books on Amazon are usually the least qualified people to do that. Sure, they can tell how easy the book was to read and how well they picked up what the author taught them. But they have no way of knowing whether what they learned was accurate or useful.
- Amazon ratings last forever. But, as noted above, the quality of a technical book in a fast-moving subject like programming falls over time. Perhaps Amazon ratings on programming books should have a half-life.
Here are some examples of things that you’re going to miss out on by using outdated Perl references.
- say – We all love say, don’t we?
- Lexical filehandles – Storing filehandles in lexical variables is great. I no longer have to worry about bareword filehandles being reused elsewhere in the code.
- Defined or operator – There’s now no excuse for the $val ||= $default bug.
- given/when – Perl has a switch statement. And it’s better than anyone else’s 🙂
- Unicode support – Perl’s Unicode support is second to none. Except, if you’re using an old version of Perl in which case it’s a bit rubbish. And if you’re reading about Perl in an old book, then you won’t know about it.
- State variables – Ok, I don’t use those every day. But when I need them, they make my code cleaner.
And then there are all the great CPAN modules that aren’t covered in books that were written before they were released. Would you really want to introduce someone to OO Perl without mentioning Moose?
My rules for recommending books are pretty simple. They should be books that I’ve found useful and they should have been published in the last few years. And given the falling numbers of Perl books that are published each year, that’s now a rather small number of books. Perhaps a dozen or so.
Am I being too harsh? Can beginners get something useful out of older Perl books? How do you decide whether to recommend a book to a colleague?
Half jokingly: when learning from old books they wouldn’t meet the not so smart “smart operator”…
So could you recommend one that you don’t rule out, and put a date next to it?
given/when are great – as an idea. The reality of their specific design is quite different.
I think there are some older Perl books that still have some value. You can tell a new Perl developer to learn all the modern constructs like the ones you mentioned and they will be able to write some really nice code, but when they also have to maintain code written when version 5.8 reigned supreme (or even 5.005), these new developers would be lost. With that in mind, people should know about what was mentioned in books like “Perl Cookbook”, both editions of “Advanced Perl Programming”, “Intermediate Perl” and “Learning Perl Objects, References, and Modules”.
Oh, I agree completely. Which is why I wrote “But I really wouldn’t want anyone to read them if they didn’t already have enough experience to update the Perl to current best practices.”
It’s worth pointing out that there’s a very recent edition of “Intermediate Perl” (Aug 2012). And also, “Learning Perl Objects, References and Modules” was given a new title – it’s now called “Intermediate Perl”.
oh, shoot. I must have missed the memo on the new edition of Intermediate Perl. Going to run out and get it asap!
Lexical filehandles (well, lexical *references* to file handles) have been possible since 5.000, which predates most Perl books.
Hardly anyone used them.
It wasn’t until filehandles autovivified (in 5.6.0) that lexical filehandles became popular. Before that, people prefered to use bare word file handles over typing a short extra line.
I agree with your argument that teaching from out of date sources is not ideal. However, I have had to teach a number of newbies Perl, and for many, this is the first programming language they have ever dealt with. In that case, I am more interested in the teaching methodology for building a foundation of skills. I use a combination of books, including Lerner’s “CORE Perl” (very out of date) and Schwartz “Learning Perl” with its student workbook (covers up to Perl 5.10). Once they get over struggling with the mechanics of the language and the concept of programming, it is easy to introduce them to the more modern aspects of Perl, like the say and given verbs, lexical filehandles, and unicode.
One last point (and HTML and CSS share this same issue with Perl), just because something is the latest and greatest does not mean you should use it. If you write software for a living, and have to install that software in a variety of environments, it is very likely that some of your target environments will not be running the latest version of Perl. Some of my not-for-profit association clients run Perl 5.6 and 5.8 in order to run legacy applications they don’t understand, written by people long gone from their organization. If the client is unwilling to upgrade, you need to write your application so it will run in any environment.
Sure, I wish I had the power to force all of my clients to move to Perl 5.16, but I don’t. And my competitors are more than willing to accept client systems as is, so if I want to do business, my applications need to deal with out of date releases of Perl. So instead of “say”, I use “print” and stick a newline on the end. I do keep a list of which versions of Perl my clients use, and I gently push my clients to upgrade. But it is a slow, tedious process. We are experimenting now with shipping our applications on a disk that gets mounted into a standalone system — this gets around the out of date Perl problem. So far, we have had very little push back from the clients we have offered this to.
Dave, you should take a look at perlbrew if you don’t know about it already. It will let you compile newer and older versions of Perl on a system and keep them isolated from one another. The legacy apps can use the old system Perl while your newer application can use a newer version of Perl.
Steven, thanks for the tip. For some reason I was not aware of Perlbrew. I am going to install it on one of my systems this afternoon and play with it. It appears to be a great workaround for a problem that has been driving me nuts for a long time. Thanks.
I think pointing people at Chromatic’s modern Perl book would be good. I think older books are valuable to more experience programmers.
What do people think about having TPF provide grants to fund creating free books for new or beginning users?
It could be a separate funding drive, this might be one way to bring new blood into Perl and provide guidance in modern techniques to beginning (or returning) coders.
I love the Modern Perl as whole – the book, the blog, the module and it’s development model. It is all together facsinating and book lives at Github and evolves with time like a FOSS project should. Very nice! Maybe not best for absolute beginners, but having already some basic knowledge about programming, it gives pretty good introduction into modern Perl world.
Do you have a list of books that you would recommend? I have trouble thinking of more than 2 or 3 modern Perl books that are worth reading, so I would like to see the dozen that you quote.
Besides the books already mentioned, I liked brian d foy’s “Effective Perl Programming” (http://www.effectiveperlprogramming.com/). It’s a good series, the Java one was also very useful.
C.
Mastering Regular Expressions and Higher Order Perl are two that have been around for a while but are still magnificent. Neither are beginner’s books though.