4 ms·
Python and Perl have almost exactly the same OO model, yet many people quite like Python's OO, so that can't be it surely... There's no private data or private
by jlokier 7y ago
Python and Perl have almost exactly the same OO model, yet many people quite like Python's OO, so that can't be it surely...
There's no private data or private methods in Python objects. All the properties are right there for anyone to read, protected only by convention.
JavaScript and Perl have almost exactly the same OO model, yet many people quite like JavaScript's OO, so that can't be it, surely...
There's no private data or private methods in JavaScript objects. All the properties are right there for anyone to read, protected only by convention.
(It's closer than it looks. Perl's "bless" function means almost the same as JavaScript's ".__proto__ =", and inside-out data hiding is possible in JavaScript much the same as Perl, although hardly anyone uses it in either language.)
- hnick 7y agoI'm not necessarily a fan of the OO in those either :) I try to use OO sparingly when possible, and in Perl that generally just means I've been using a hash and decide it'd be more convenient that it keep some functions to itself rather than pass it around to other functions. I will say in Perl's defense, the bare implementation really made me appreciate what OO actually is under the hood. I felt like I understood it much better, especially since it takes a mixed approach (rather than 'everything must be an object, including Program.cs' which I never really enjoyed).
- Grinnz 7y agoIt does make it very clear that it is just a data structure (state) associated with a class (behavior).
- tyingq 7y agoIt's also pretty neat that you can bless any type as an object. People use the hash most often for obvious reasons, but you can use a scalar/string, array, etc, if you wish.