undeclare.pl: MooseX::Declare -> Moose

Our current project at my job is based solely on rather sophisticated object model, we've chosen MooseX::Declare as one of our main helpers. We are very happy with compiletime argument checks, I guess it saves us a lot of debugging time. Unfortunately our app performance was far from satisfying; the profiling showed it was MXD's fault. Also, we found an enlightening benchmark.

The problem was solved by implementing a tool that allowed us to have two variants of our codebase: development and release. Release is prepared by translating method declarations with method signatures into plain perl subs with parameters parsing. This job is done by undeclare.pl, it uses PPI to parse and transform .pm files.

Some of our domain-specific tests now run more than 10 times faster.

7 Comments

> We are very happy with compiletime argument checks


Actually, they're performed at runtime. In fact, MooseX::Declare methods aren't even declared until runtime. If the checks could be performed at compile time, perl wouldn't be perl, Perl wouldn't be Perl, and undeclare.pl wouldn't be necessary :-)


An alternative approach might be to propose a patch for MooseX::Method::Signatures to allow its goodness to be disabled for production e.g. through a $MOOSEX_METHOD_SIGNATURES_DISABLE environment variable.

Couldn't disabling MooseX::Method::Signatures produce funny side effects wrt. type coercion?

--Steffen

> Couldn't disabling MooseX::Method::Signatures produce funny side
> effects wrt. type coercion?


Yes, and defaults would have to be preserved as well. That's what would make the patch such fun to work on :-)

Leave a comment

About komarov

user-pic I blog about Perl.