2013-02-06

Learning JavaScript via other languages

Looking back on my life, three programming languages prepared me well for JavaScript (which has some challenging aspects):
  • Scheme: In my first semester of Informatics, I had the great fortune of being taught Scheme via the classic “Structure and Interpretation of Computer Programs” (free online). Due to Scheme, JavaScript has closures [1]. Furthermore, Racket (a Scheme dialect) inspired ECMAScript 6’s approach to privacy, private symbols [2].
  • Self: Later, I took a cursory look at prototype-based object-oriented languages. One paper was especially insightful: “Organizing Programs Without Classes”. Class-based languages have two relationships: instance-of (between objects and classes) and subclass-of (between classes). Prototype-based languages manage with just one relationship: has-prototype (between objects). How you organize things is still very similar in both kinds of languages, as the very readable paper explains, via the programming language Self (another one of JavaScript’s original influences).
  • Java: Java holds three leassons for JavaScript. First, it helps with most of its syntax – the original mandate for JavaScript was that its syntax had to look like Java’s [1]. Second, it helps with object-oriented programming, even though it sometimes feels a bit rigid. The book “Effective Java” (affiliate link) is a great primer on Java issues, many of which are relevant for other OOP languages. Third, you get an idea of what good IDEs can do. JavaScript still has some catching up to do in this area.
While there are other languages that can teach you something about JavaScript, these three stood out for me.

References

  1. JavaScript: how it all began
  2. Private data for objects in JavaScript

No comments: