3 ms·
> I don’t think one can call a blessed hash (or scalar for the fancy folks) an object _system_. Perl first, then JavaScript. Did you know JavaScript classes a
by jlokier 6y ago
> I don’t think one can call a blessed hash (or scalar for the fancy folks) an object _system_.
Perl first, then JavaScript.
Did you know JavaScript classes are blessed hashes?
They even take about the same amount of syntax. ("__proto__" vs "blessed", "prototype" vs "bless").
Old JavaScript made the blessing crude and obvious.
Modern JavaScript lets you hide it in a "class" decleration. Which you can also do in Perl if you want (though you'll need to choose a module for this, and people generally prefer a different approach to dressing up objects in Perl.)
There's still a blessed hash under the hood which you can see and kind of have to be aware of... in both languages.
- daotoad 6y agoPerl and JavaScript both give you a minimally specified set of tools you can use to build your own more advanced object system. IMO, that's why both languages have been able to be extended and adapt so much. If you look at tools like Moo and Moose in Perl and the different coding paradigms that evolved in JS before the "class" keyword was standardized, this is pretty clearly evident. JS has had the advantage of a standards committee pushing new language features aggressively. Perl has moved more slowly, keeping a majority of functionality in libraries.
- jqcoffey 6y ago> Did you know JavaScript classes are blessed hashes? > They even take about the same amount of syntax. ("__proto__" vs "blessed", "prototype" vs "bless"). omg, I totally forgot that (I left day-to-day JS use a good decade ago, sorry!).
- lmm 6y agoTraditional JavaScript has a notoriously poor object system yes. If those are the only two languages you know then I guess Perl's object system doesn't seem so bad, but that shouldn't be a defense of either language.