Back in March, I mentioned that I was working on a new OO tutorial for the Perl 5 core. I’ve been working this intermittently over the last eight months or so, with lots of useful feedback from the perl5-porters. Along the way, the project grew to include a rewrite of the perlobj document, the reference document for Perl OO.
I’m happy to say that as of last week, all of my work has been merged into the blead branch of core, and will be in the next release of Perl.
Here’s what I did …
We now have an entirely new OO tutorial. This tutorial has two parts. The first is an introduction to OO concepts. Some people may come to Perl without a background in another OO language, so defining basic concepts is important. This part defines these concepts in terms of how Perl implements them, so even if the reader has some OO background, skimming this section will still be useful.
The second half introduces three OO systems from CPAN and gives short examples of how to use each one. In 2011, it just doesn’t make any sense to tell people how to roll their own OO code in a tutorial. The systems I wrote about are Moose, Class::Accessor, and Object::Tiny. I also mention Role::Tiny, since roles are awesome, and you shouldn’t have to use Moose to use roles.
When I merged this tutorial, I deleted all the old tutorials. Those were perltoot (Tom’s object-oriented tutorial for perl), perltooc (Tom’s OO Tutorial for Class Data in Perl), perlboot (Beginner’s Object-Oriented Tutorial). I also removed perlbot (Bag o’ Object Tricks (the BOT)). All of these were extremely outdated and contained a number of dubious recommendations.
Don’t take this as a criticism of Tom, Randal, or other people who worked hard on those docs. They were great when they were written, but the state of the art in Perl OO has changed a lot in the past 10-15 years. If Perl 5 is still in use 10 years from now, someone will be deleting my tutorial then!
I also revised perlobj. Some of the old content remains, but it has been rewritten, reordered, and expanded. I hope that it is now a 100% complete reference to core Perl OO features.
If anyone reading this has any constructive feedback on these docs, I’d love to hear it. I really want to get these new docs into excellent shape before Perl 5.16 ships in spring of 2012.