I am using perlclass syntax whenever I write a new module, and I often rewrite an existing one when I make other changes to it.
I had moved from blessed classes to Moose long ago and found it rewarding to rewrite when I touched old code. I find Moo(se) classes easier to read and Moo(se) brings a lot of convenience (validation, delegations, coercions) so that I could eliminate some subroutines.
The new core OOP still lacks most of these convenience features, I just shrug it away... because I can afford it.
Some random observations:
- I prefer the core OOP keywords to Moo(se) syntax. Moose was a game changer, and also a showcase what you can do with the Perl interpreter, but it is bound to Perl syntax with its imported routines. Moose took care for that by defining conventions:
has 'x' => (is => 'rw', isa => 'Int');
That is a clever use of the fat comma and superfluous parentheses. To the Perl interpreter it looks the same as the less readable alternatives
has('x','is','rw','isa','Int');
has(qw/x is rw isa Int/);
In core OOP, you write:
field $x :reader :writer; # no types (yet)
To be fair, this has its own quirks due to the way attributes are parsed by the interpreter. One can write that like that:
field $x : reader writer;
This is quite a challenge for syntax-aware editors...
- Core OOP has no roles (yet). I usually work around that by converting the role to a class and making its objects fields of the class "consuming" the role. Several times I found that I actually prefer this "has-a" relationship.
- The Perl debugger and various data dumpers and serializers do not (yet) work on core objects. I like to use the debugger, my approach is cheating: I use Feature::Compat::Class and let it fall back to Object::Pad which provides a meta object protocol which can be used by the debugger.