Getting started with Moose (Was: Re: Google App Engine -- with Perl)

Tomas Doran bobtfish at
Sun Jul 27 11:41:52 BST 2008

On 27 Jul 2008, at 00:40, Dave Hodgkinson wrote:
> I'm kind of vaguely seduced by moose, mainly by CL making antler  
> gestures.
> And the assertive, declarative nature of it.
> Is there anything in the wild about:
> 1. Cookbooky things. How to do cool stuff in isolation.

I assume that the Moose cookbook isn't what you're looking for?  

I went from reading the basic docs, and the first few examples in  
here, through to trying to build something, and re-visiting the  
cookbook / docs when I needed / knew I didn't know how to do what I  
wanted to do (but that Moose should be able to do it for me).

Also, I can't say enough good words about the people inhabiting  
#moose - if the docs aren't making it clear to you then they will get  
you sorted out. :)

> 2. How to moosify existing shitty codebases.

There isn't too much documentation on how to do this specifically,  
but, assuming that you've already got an OO style codebase, then it  
isn't too hard - I'd probably start by working out how to act like  
whatever type of accessor generation they're using, factoring that  
out (e.g. Moose::Policy::PBP and/or  
MooseX::Emulate::Class::Accessor::Fast), and then replacing the old  
attributes with Moosey ones.. (Remembering to say 'no Moose' when you  
get back to the original code to avoid clashes with Moose symbols).

Once you've got all the setters/getters ported (and everything using  
them), you've got quite a lot of Moose's power already - e.g. the  
'handles' parameter of the attribute metaobject can be used to move  
your object logic around/install delegators for things trivially  
(useful for pushing methods down, which is one of the first things  
after enforcing basic sanity I find myself doing). There are  
obviously many more tricks that become much easier, this is just a  
trivial example.

I can't really say much about trying to convert a complex inheritance  
hierarchy to the use of roles / etc (which would probably be my next  
step), as I haven't done this yet..

Again, I'd recommend surveying the lay of the land, and then asking  
#moose about anything where you're not sure about the recommended  

Whilst I wouldn't describe Catalyst as 'shitty', it does have plenty  
of hysterical raisins, and they've ported it - so I would conclude  
that it's possible, and that there is a load of experience porting  
stuff floating around - just that there hasn't been that much writing  
down of it yet ;/


More information about the mailing list