JavaScript or rather JS1.0 is mostly a baby Perl with Java syntax. The prototype object system from Self being the main difference (objects are kind of blessed hashes which inherit from other objects not classes)

The claimed functional influence from Scheme is already present in Perl5. ( sub returns a function reference, making functions a first class object which can be treated like variables)

Block scoping was later introduced into JS with let . ( var is a mess )

The operators you list derive from C, a common predecessor for Perl and Java.

Actually "typecasting" in JS is a major problem, JS has no "scalars".

To better explain, there are two major ways to do dynamic typing.

A) a type is determined when initializing.

Like in Python where 3/2 is 1.

Why? Because 3 and 2 are integers. (Python introduced something like // later to address the confusion)

B) a type is determined by the operator.

Like in Perl where 3/2 is 1.5 and 3 . 2 is 32

JavaScript is a mongrel of both systems,

and the rules how + behaves confuse(d) the shit out of people.

You can remember that 1 + "1" is "11", but what will happen if you don't have full control about the types in the variables of a + b ?

JS programmers must resort to tricks like

'a+b+0' or 'a+b+""'

(IIRC, this depends on precedence and I have to look it up to be sure UPDATE guess what, I got it wrong, have to correct this later.

What's sure is that a+=0 becomes a number and a+="" a string )

Perl fixed this with a lot of operators, but people complain that the code looks unreadable, because of all the symbols.

But Brendan had 10 days to design the language which had to look like Java...

They fixed a lot of stuff in the meantime and introduced some nice python features.

But it's still annoying not to have pure hashes in JS ...

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery


In reply to Re^2: Proving that Perl influenced JavaScript for WP by LanX
in thread Proving that Perl influenced JavaScript for WP by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.