Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: A "Perl-7" that I could actually USE right now

by tobyink (Canon)
on Jun 23, 2013 at 14:40 UTC ( #1040325=note: print w/replies, xml ) Need Help??

in reply to Re: A "Perl-7" that I could actually USE right now
in thread A "Perl-7" that I could actually USE right now

For what it's worth, Mouse is much more than 25% faster than Moose (at least it is on machines where it's been compiled with XS; Mouse::PurePerl is very slightly slower than Moose). While it appears to offer good compatibility with Moose; this is on the surface only. Things start to break if you try to consume a Mouse role in Moose, or extend a Moose class with Mouse.

Moo has far less of a start-up penalty than Moose, but when it comes to running speed, isn't quite as fast. On the surface it appears less Moose-compatible (but see MooX::late) but it's designed to be able to interact nicely with Moose. You can extend Moo classes with Moose, consume Moose roles in Moo, etc.

The only places I can see big scope for Moose optimization are:

  • Allow inlining for things like defaults, triggers and coercions. This would slow down the speed at which your class loads, but improve the speed at which it runs.
  • Rewrite large parts of the internals in XS. This would likely improve the speed of Moose itself, but not alter the speed of your class. (It would also make maintenance of Moose more annoying, and thus turn away developers.)

I've published a couple of modules on CPAN that might be of use if you're trying to eke a little more speed out of a lumbering Moose...

  • Type::Tiny - a type constraint system that's a little faster than Moose's built-in ones. (I have benchmarked it.)
  • MooseX::XSAccessor - which replaces some of your accessor methods with faster XS-based ones, but only when it detects that it can do so without breaking any functionality. (Again, I have benchmarked it.)
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
  • Comment on Re^2: A "Perl-7" that I could actually USE right now

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2020-11-28 05:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found