http://www.perlmonks.org?node_id=1017386

With all the hype being thrown about Python v Perl and my own baby steps into Moose, I thought I'd have a quick look at how the other side does it and found both quite comparable. Not knowing any Python, I grabbed some code from a tutorial page and tried to implement the same 2 attribute, 1 method class in Moose.
Python
class OurClass(object): """Class docstring.""" def __init__(self, arg1, arg2): """Method docstring.""" self.arg1 = arg1 self.arg2 = arg2 def printargs(self): """Method docstring.""" print self.arg1 print self.arg2
Perl
package OurClass; use Moose; has ‘arg1’ => ( is => ‘rw’ ); has ‘arg2’ => ( is => ‘rw’ ); sub printargs { my $self = shift; say $self->arg1; say $self->arg2; } no Moose;
For those who like their statistics simplistic:
  • Python (29 words, 190 chars)
  • Perl (25 words, 142 chars)

    Rather than seeking approval from any self-appointed echo chamber, I'm wondering if there are any here with the Python chops to tell me that I've created a straw man (like missing out the call to __PACKAGE__->meta->make_immutable;) or that there's a Python feature specific to OO that they really wish was in Moose or implemented more naturally.

    I'm not trying to get anyone's back up, just meditating on how to make the comparison fair.

    best,

    Sometimes I can think of 6 impossible LDAP attributes before breakfast.