2013-02-24

Perl and Python influences in JavaScript

If you search the Mozilla Central code base for the texts "Perl" and "Python" (don’t ignore case) then the comments mention what methods have been borrowed from those languages. The paths mentioned below are relative to /js/src/.
[Inspiration: a blog post by Ziyun Fei.]

Perl influences in ECMAScript 5

String (jsstr.cpp):
  • String.prototype.match()
  • String.prototype.replace()
  • String.prototype.split()
  • String.prototype.substr()
Array (jsarray.cpp):
  • Array.prototype.join()
  • Array.prototype.reverse()
  • Array.prototype.sort()
  • Array.prototype.push()
  • Array.prototype.pop()
  • Array.prototype.shift()
  • Array.prototype.unshift()
  • Array.prototype.splice()
RegExp (builtin/RegExp.cpp): generally Perl-inspired, one comment attests to that fact.

Python influences in ECMAScript 5

String (jsstr.cpp):
  • String.prototype.concat()
  • String.prototype.slice()
  • String.prototype.match()
Array (jsarray.cpp):
  • Array.prototype.concat()
  • Array.prototype.slice()

ECMAScript 6

ECMAScript 6 has been influenced by several languages. Examples:
  • Arrow functions [1] and classes [2] have been inspired by CoffeeScript.
  • Comprehensions [3] and generators [4] have been inspired by Python.

References

  1. ECMAScript.next: arrow functions and method definitions
  2. ECMAScript.next: classes
  3. ECMAScript.next: array comprehensions and generator comprehensions
  4. ECMAScript.next: for-of, iterators, generators

No comments: