Many moons ago, I lamented about the poor state of Perl's object-orientation. Python and Ruby are more closely integrated with OO, and Perl 6 seems like it's always going to be a long way away. (I predict that Perl 6.0.0 will hit the red carpet on December 25, 2010.)

It turns out that rather than cursing Perl 5's OO darkness, someone lit a candle, and the name of that candle is Moose. If Moose is too much for you, there's a one-note-spelled-L-I-T-E version called Mouse. Mouse, they say, is "Moose minus the antlers".

Looks promising.

Update: OK, having known nothing about Moose or Mouse prior to tonight, I decided to take a stab at a basic Perl 5 class, enriched with new, Mousy goodness. It is surprisingly good, barely more verbose than Ruby's own accessor declarations:

package Human;
use Mouse;

has 'name' => (is => 'rw', isa => 'Str');
has 'age' => (is => 'rw', isa => 'Int');

1 comment:

Steven Huwig said...

Did you catch the news that Higher Order Perl is now freely available online?