Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Trying to understand Perl Objects

by TGI (Vicar)
on Apr 06, 2009 at 21:03 UTC ( #755857=note: print w/ replies, xml ) Need Help??


in reply to Trying to understand Perl Objects

OOP in Perl has a very strong DIY flavor. As a result, there are all sorts of ways to build your objects in Perl: classical methods with blessed hash or array refs, inside out objects, and even more exotic XS based objects.

You can do all the work yourself each time you write a new OOP module and implement all your accessors and mutators, type validation, and so forth manually. Or you can use one of the many modules to help automate the process.

I have found that two ways of generating object code work well for me.

For dirt simple objects that are used to contain some data and bind a few methods to the data structure, Class::Struct does a very nice job. It is very limited and somewhat brain-dead (eg. can't use it in subclasses), but for very, very simple tasks, it reduces a lot of busy-work, and I can understand exactly what it does.

For anything with more than the most minimal demands, Moose is the way to go. It provides much of the goodness we will see with Perl6 objects. I've used it for a few projects now, and it is really quite amazing.

For an example of why Moose is so great see the Moose Unsweetened document for a comparison of manual and Moose object code.

Perl 6 is not even fully specified, and is certainly not ready for prime time. The Parrot VM just released version 1.0 which provides a stable API for language implementors, but is still not 100% ready for production use--that will come in 2.0. Both projects are cruising along, but both are far from being ready for production use. If you want perl 6 oo, with roles and type checking, etc. Moose is the best way to get it now.


TGI says moo


Comment on Re: Trying to understand Perl Objects

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://755857]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2014-12-17 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (31 votes), past polls