http://qs321.pair.com?node_id=11116992


in reply to Cor—An object system for the Perl core

From the wiki:
Cor must be better than what you can get in Python 3, Ruby, Swift, and so on.
That would be really nice (and I do appreciate the effort put into this), but some reasons I think it falls short of being truly better:

1. No autoboxing. What if you'd used a plain hash instead of Hash::Ordered? In Python/Ruby e.g. it's nice that when dealing with hashes and arrays you can call methods on them so there isn't the kind of mental switching between OO and procedural that we must do in Perl.

2. Lack of uniformity between built in containers and user defined ones. In the Hash::Ordered docs there is this snippet:

$oh->add( 'a', 5 ); # like $oh{a} += 5 $oh->concat( 'a', 'hello' ); # like $oh{a} .= 'hello'
I don't get the impression Cor would actually let both of those work. Whereas in Python this would look like:
>>> h = {'a' : 1} >>> h['a'] += 2 >>> h {'a': 3} >>> >>> from collections import OrderedDict >>> oh = OrderedDict(h) >>> oh OrderedDict([('a', 3)]) >>> oh['a'] += 2 >>> oh OrderedDict([('a', 5)]) >>> oh['b'] = 'hello' >>> oh['b'] += ' world' >>> oh OrderedDict([('a', 5), ('b', 'hello world')])

3. We're still conflating interfaces and implementations (surely we can do better?). I'd really wish class definitions to be more self documenting so I can first get an overview of what it does, and then focus on the "how". FWIW, I did a proof of concept of what this could be like. So e.g. the first thing you see is the "what" which can be more rich than just a list of methods (contracts in fact).

Replies are listed 'Best First'.
Re^2: Cor—An object system for the Perl core
by Ovid (Cardinal) on May 20, 2020 at 21:33 UTC

    Maybe we'll do autoboxing later (I doubt it, but who knows?), but that falls outside the scope of an MVP.

    As for your other points, maybe join the IRC channel? Some of your points come down to different opinions about how to define and approach correctness and that's often very subjective.