On Oct 22, 2010, at 4:07 PM, Nick Perez wrote:
On Fri, 22 Oct 2010 12:41:52 -0700
Buddy Burden <[email protected]> wrote:
Also, am I incorrect in believing that _all_ the overhead of
MX::Declare is in the startup?
It depends on what features you use. If you are a heavy method
signatures user, like me, it indeed will have a run-time performance
hit, but it would have that any way if you validated all of your
parameters by hand via type constraints or using
MooseX::Params::Validate.
Actually that is not entirely true, if I recall correctly MX::Declare
wraps the method call in a subroutine that itself does some method
calls to validate args, etc. And in some cases (with return value type
checks) there is perhaps even another layer of wrapping as well. So
that is possibly multiple layers of subroutine call stack, a couple
method calls and the Moose type checks which themselves use
MooseX::Types::Structured which then calls the Moose type checks
themselves.
These layers add fairly significantly to the method call overhead,
whereas MX::Params::Validate is simply a couple subroutine (not
method) calls along with the Moose type checks (most of which will use
the optimized versions directly, or at least as a basis of the type
check).
For me, I'd always prefer correct over fast.
Yup, 100% agree on that.
And method signatures provide a much more compact syntax for parameter
validation than using other, more manual methods.
Also can't argue with that, however I will say that
MX::Params::Validate isn't really that much extra ugly so the tradeoff
isn't too bad.
- Stevan