Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Just curious, why do you prefer OIO over Moose?

    • by Yanick (3196) on 2008.07.20 10:31 (#63963) Homepage Journal

      As I said, it's merely a preference. There's nothing that I found so far that is a show-stopper or an overwhelming advantage for any of them. This being said...

      The biggest plus of OIO, for me, is how inside-out objects ensure that colliding fields are not clobbered, but masked:

      package Foo;
      use Moose;
      has 'x' => ( default => 'foo', is => 'rw' );

      package Bar;
      use Moose;
      extends 'Foo';
      has 'x' => ( +default => 'bar' );

      package main;
      my $obj = Bar->new;
      say $obj->x;        # prints 'bar'
      say $obj->Foo::x;   # prints 'bar'

      package Foo;
      use Object::InsideOut;
      my @x : Field :Acc('x') :Default('foo');

      package Bar;
      use Object::InsideOut 'Foo';
      my @x :Field :Acc('x') :Default('bar');

      package main;
      my $obj = Bar->new;
      say $obj->x;        # prints 'bar'
      say $obj->Foo::x;   # prints 'foo'

      I know it's a little bit of a paranoid concern, and it creates a little bit more work (as you have to completly create two '@x's instead of overloading the one from Foo in Bar), but hey, it soothes the obsessive-compulsive in me. :-)

      Another argument for OIO is that it claims to produces accessors that are faster than the ones of the usual blessed hash objects. Now, it must be said that I didn't benchmark that claim, so I can't vouch for it. Nor do I really need blinding speed for the stuff that I usually do. But just like the guy shopping for BBQs, I'm atavisticly drawn to the beast that boast the most BTUs. :-)

      There is also the documentation. Moose's doc is getting good, but it's still a little bit scattered and hard to put together. OIO's, on the other hand, is very comprehensive. It's also a bit lenghty and hard to use a quick reference, but hopefully my cheatsheet is taking care of that problem.

      And OIO can also play quite nicely with non-OIO objects. You can easily inherit of a blessed hash object (which could be a Moose object!), and a lot of the required magic will be done for you.

      On the other hand, Moose does offer a couple of features that isn't in OIO (being able to slap 'before' and 'after' pieces of code around your parent class' methods, for example), but so far I didn't feel the need for them.