http://www.perlmonks.org?node_id=896559


in reply to OO and Perl

There are two camps of learning Perl OO. The first is that you should learn all the various pieces of building an OO system and grab modules off CPAN that do individual things. This is the traditional way of doing OO in Perl.

The other is to start with Moose which is a great system that does everything you need.

I am strongly in favor starting with Moose. Why? Several reasons. OO is all about abstraction and composition and interfaces. It is about burying how your code does it's work and focusing on just that it does what it says it does. Digging into the nitty gritty details of building an OO system and picking and choosing your pieces is the antithesis of that.

Moose has everything you need all in one package. Roles, attributes, introspection... it's all there. The bits and bobs on CPAN? They each implement part of the problem. Maybe they work together, maybe they don't.

Moose is very heavy, but if it's too heavy for you there's Mouse which has no dependencies. They interoperate well and there's Any::Moose to decide between them.

TMTOWTDI but Moose is a pretty good one which Perl 5 is (finally) converging on. You can write a Moose class and be pretty sure any given Perl programmer will understand it. If they don't, they just have to learn one module... one they're going to have to learn anyway. If you need advice, you can get it. If you write something by hand or pull bits off CPAN, who knows if it's a module someone is familiar with.

Finally, the stuff in the core docs is really, really, really out of date and gives some bad advice. It's far too focused on HOW to build an OO system and not what you should be doing with it.

Replies are listed 'Best First'.
Re^2: OO and Perl
by nikosv (Deacon) on Apr 01, 2011 at 17:21 UTC
Re^2: OO and Perl
by Anonymous Monk on Mar 31, 2011 at 06:14 UTC
    BTW how is Perl5i going?