and when the novice hits the limits of this new system they can then be introduced to the many other ways that Perl has for working with OO
The problem with this approach might be that people will use it, hit that limit and complain loudly about the "very limited OO support in Perl".
If 'class' would use the keyword "constructor" for a proper constructor method AND allow it to return undef, we'd be half there i think. And 'class' could just provide a default "new()" constructor if none if given.
Stuff like "you can have multiple constructors" would be in the advanced section of the documentation, just like "multiple inheritance", "writing factories", and so on.
If, say, i start a new project and get a newbie programmer sidekick, i would be forced to ban 'class' at the moment and force thew newbie to use bless() anyway. Simply because 'class' is too limited in scope and i would want to avoid a mixture of both in a project. Especially because those use a very different way of doing things and switching a module from 'class' to 'bless' would mean a very major rewrite.
Which, BTW, is the other thing that feels totally wrong to me. Not only does it seem to be a bad idea to force potential rewrites of an entire OO project on future perl users when they exceed the "novice" levels, but it looks to me like a potential PR problem as well.
As i said, if we really add another, "more modern" way of doing OO in Perl, it should be more powerful and "perlishly flexible" than what we already got, while at the same time easier to understand. With a few small changes, 'class' could be that solution.
I'm not a big fan of the attitude of "optimize for beginners". I started programming using BASIC (on old Commodore machines). And i must say, it was kind of frustrating hitting the limits of the language, then having to throw away most of my knowledge and learn a completely different language. Yes, BASIC was "optimized" for beginners. But had Commodore given us a C compiler instead, it wouldn't have been a much steeper learning curve and there just wouldn't have been frustrating, artificial limits imposed by the language.
In my opinion, the ability of a language should suffice for experts, but at the basics should be easy for novices to learn. Without limiting their ability to use already learned stuff later when they start to climb their ladder to become an expert.
|