I absolutely love that Cor is being adopted into Perl and have done a lot of experimenting with it, but I’m very conflicted about introducing it as the canonical way to write OO Perl in Exercism.
The fact of the matter, to me, is that most people learning Perl in 2024 and onward are going to see a lot more legacy code than greenfield projects. Legacy code simply will not be using the built-in feature class
for many years. I feel that we’d be doing students a disservice by encouraging users to adopt techniques that they won’t actually see in production, while at the same time failing to teach them about existing methods that they will see.
Perl versions is definitely a concern. Debian Stable still only has v5.36, and Testing is likely to go Stable next year, so it is fairly likely to be stuck at 5.40 or 5.42. It is unlikely that feature class
will be as complete as other implementations by then, so that could mean at least around 4 years before Debian has comprehensive support. 5.40 just got the :reader
attribute and still does not have the :writer
attribute (this is in Object::Pad
but there’s no guarantee that it will make it into 5.42, I don’t think).
That said, I’m ambivalent about Moo also. If we must use an external module, I might actually lean more towards full-fat Moose instead. I personally prefer to use the more light-weight Moo, but I see Moose more often in the wild, and it is also the one that is most often discussed in books (it is used in Modern Perl, which I think is the gold-standard for Perl books and which is available for free online).
If we are concerned about external dependencies, we could just teach people to bless those references! For most exercises, it would be completely sufficient and given that the setup for Moo objects are already defined in the stubs, the setup for blessed references would be done for them also… People don’t really have to understand what either are doing at a deeper level. I don’t thing that there are any exercises that are dependent upon the advanced OO features which get simplified away by any of the existing modules or by Cor.
I know that a lot of people do not like blessed references, however, I don’t entirely understand why. They build very naturally on simpler Perl concepts (ie. classes as packages, methods as functions, and addressing object data from the blessed references exactly how you would expect to in many other languages: $obj->{'data'}
) using just a couple of extra keywords. Moo uses these under the hood anyways, so it is not a bad thing to expose students to things like @ISA
being used to track parents, etc., even if they do move on to something more mature for their own projects eventually.