JavaScript and Perl Object-orientation: a small comparison

I began programming Perl in 1997, as my university did not
run Netscape Live Server – the original server-side JavaScript –
and I wanted to access to a database.

So many years later, it looks as if JavaScript is back in
a serious way: despite limitations in the implimentations
of ECMA Script, the standard of which JS is now a subset,
the language is more powerful than the average Perl
developer is lead to believe.

Perl programmers tend to frown on JS as a toy language,
the way C++ devlopers look down on Perl developers.
Yet Perl and JavaScript have an awful lot in common:
both are easy to exten, bothd in their own syntax and
in the C; both are regularly extended with library
frameworks (Moose, MooTools).

Whilst both have a slightly unusual approach to OO,
the main conceptual difference is that JavaScript is
OO to a much great extent than Perl. For example, whereas
Perl has a length() function, JS objects have a length() method.
More interestingly, JavaScript’s object orientation is
prototype-based – there are no classes, only objects and
object instances, based on functions that operate upon a
built-in “this” variable, and which are used to generate
instances of custom objects when called with the “new” keyword.


This page contains JavaScript which
is documented, in comparison with Perl:
A comparison between
common OO features of Perl and JavaScript