Starting from the top

Topic: WTF JavaScript

This is the first series in the WTF Javascript topic about JavaScript.

JavaScript is the most common term that is used when people are referring to…JavaScript 😑 - but there are quite a few other ways that folks refer to JavaScript that freaked me out when I started writing code again a couple of years ago:

  • ES5
  • ES6
  • ES 2015
  • ECMAScript
  • CommonJS
  • TypeScript

To cut through all of this noise and start to see things clearer I have to keep reminding myself that JavaScript is actually…just a specification. A document. You can print it out on paper. JavaScript itself isn’t a technology, but only a description of how a technology should work.

There is no one JavaScript. There is no single place you get it like you might pick up an iPhone at an Apple store.

JavaScript is just a document, that specifies how a language called JavaScript should work.

Various companies and individuals use that document to build JavaScript interpreters or compilers. There is a JavaScript interpreter/compiler in your web browser (most likely). For simplicities sake, I will be using interpreter and compiler interchangeably for now.

A JavaScript interpreter is given a document of JavaScript code that someone like you or I wrote (code can be written by machines too, but let’s keep this simple for now), and the interpreter reads the document. The interpreters’ job isn’t just to read the document however, it’s job is to understand the meaning of the code that was written so that the interpreter can follow the instructions that the author of the document intended.

[Cartoon written on wipe board illustrating author → interpreter → following instructions → user]

So who writes the JavaScript specification then?

Originally, a guy named Brendan Eich built the first version of JavaScript. I am not sure who wrote the specification for how JavaScript should work, but Brendan was the one that built it.

Brendan was working for Netscape, and released the first version of JavaScript in Netscape Navigator 2.0 in September 1995. For those of you who aren’t familiar with Netscape, it was the leading browser at the time…and the story of how they lost that position to IE is fascinating.

Image of Netscape Navigator 2.0 screenshot courtesy of Yoni Heisler

👉 Brendan wrote the first prototype of JavaScript in 10 days 😲

JavaScript glue for designers

Netscape wanted the JavaScript language to be the “glue language” that was easy to use for designers and “part-time programmers”.

In order for that to be a reality JavaScript would have to work in all browsers, not just Netscape.

One way to help along an agenda like this in technical circles is to have a standard created. Typically standards are named something like ISO 42.133T0 or some other incoherent name, and you get a standard created by working with an organization like Ecma International (pronounced “EK-ma”).

Netscape submitted JavaScript to ECMA International in November 1996, and an official standard language release was created called ECMAScript in June of 1997. The incoherent standards identifier for ECMAScript is ECMA-262 and ISO/IEC 16262 😫

TC39 (the people who oversee the evolution of JavaScript)

TC39 is the comittee of people who review proposals, vote and evolve the document that describes how JavaScript should work (or ECMAScript if you want to be very specific).

The proposals, meetings and agenda’s are all really transparent and up on github.

The way that the JavaScript standard evolves in through a formal process where individuals or organizations will put together a proposal, and try to build consensus within the comittee so that their proposal becomes part of the standard. If you are interested here is a document that describes how the process works exactly (it’s not as boring as you might think).

Recap

Ok, so let’s run through the list of things we understand now:

  • There is a document that specifies how JavaScript should work
  • The document is maintained by a standards comittee
  • The document itself is not JavaScript
  • Companies and individuals make JavaScript interpreters / compilers that read JavaScript documents and execute the instructions contained in them
  • The interpreters / compilers are bundled into many places, but most commonly in your web browser
  • When your web browser encounters a JavaScript document, it feeds the document to its JavaScript interpreter and executes the instructions

Now, let’s revisit where we started. We were defining JavaScript and seeking to get clarity on all of the names that are tossed around for JavaScript. Here they are again with notes on their specific meanings that should now make sense to you.

  • ECMA Script (the official standard name for JavaScript)
  • ES5 (ECMAScript Standard Version 5)
  • ES6 (ECMAScript Standard Version 6)
  • ES 2015 (Alternate name for ES5)
  • CommonJS (a grassroots standard specification project to define JavaScript outside of the browser)
  • TypeScript (a Microsoft version of JavaScript)

All of that, for a document

I believe that a lot of the confusion when trying to understand, learn and work with JavaScript has to do with not understanding what JavaScript really is. I know getting to this level of understanding helped me, I hope it helps you as well.

Next up in the series I explore Lexical Grammar, which is the way you describe how a programming language is written.


Mind your grammar
September 13, 2018