Origins of JavaScript, or ECMAscript.

Origins of JavaScript, or ECMAscript.

ECMAScript (or JavaScript), legend has it, was built in 10 days flat. In the year 1995 when I was 5 years old, Brendan Eich had been tasked with developing a scripting language for the Netscape browser.

Eich took parts of Scheme (first-class functions) and Self (prototypal inheritance) and made the syntax “look-like” that of Java. (of course he did a lot more than just that.)

The language was made for amateur scripters who wrote simple code for client-side execution. Not many had predicted that the language would become a popular choice for building dynamic websites, server side frameworks, databases and even powering drones.

Today, JavaScript is a single-threaded, non-blocking, asynchronous, concurrent language. It features a call-stack, an event-loop, a callback queue and some other APIs. Node has a call-stack and a heap.

JavaScript programmers like to use words like, “event-loop”, “non-blocking”, “callback”, “asynchronous”, “single-threaded” and “concurrency”.

Let us go back in time and see the timeline for JavaScript:

After the initial release in 1997, the first major release came in 1999 called ECMAScript 3. Post which the language was stagnant for a long time. While there was a draft for ECMAScript 4, it was never released due to lack of consensus on the featureset.

During this time, libraries like jQuery helped JS stay sane by handling browser quirks and kinks. Creative users were trying to make beautiful animations and innovative hacks for various tricks. But performance was an issue. Then began the browser performance wars. In a bid to get a bigger market share, browser vendors started optimizing Javascript execution to make run faster.

This led to a dream-run for JavaScript performance. With the launch of V8 in 2008, JavaScript was 10 -1800 times faster than previous generation compilers. This gave the language a resurgence amongst web developers. Latest browsers like Google Chrome, could run client-side scripts at blazing fast speeds. Other vendors soon caught up with their own compilers which optimised code for execution. (JIT)

Developers started handing off non-business critical calculations like template rendering to the client, thereby improving server response times and reducing loads on backend servers. Websites were suddenly faster than ever.

Mr. Douglas Crockford evangelised the language to a big extent, his book “JavaScript – The Good Parts” has eventually become a must read for most beginners.

Crockford also contributed directly to the language, most notably his specification and implementation of JSON. Today, it is the most common data format used for asynchronous browser/server communication, largely replacing XML, and is used by AJAX. AJAX made it possible for single page applications to gain popularity.

In 2009 ES5 was launched with JSON support baked into the language itself. This version also added a ‘strict mode’ aimed at capturing silent errors. According to John Resig – “This strict context prevents certain actions from being taken and throws more exceptions.”

Eventually, Ryan Dahl, a talented developer picked the event-based, non-blocking, single threaded V8 engine, developed by Google, and made Node.js® which is a JavaScript runtime for server side programming. It is inherently lightweight and efficient for non-compute heavy tasks.

As Node started getting popular, a huge ecosystem of contributors started creating and maintaining libraries to host servers, manipulate images or even stream data. Thus npm was born, which today is the largest repository of open-sourced packages in the world.

But all this while, the language itself remained almost the same. ES5 (the most widely supported version of JavaScript currently in use) was standardised in 2009. Since then the “Ecma International, Technical Committee 39” has been working on introducing new features to the subsequent releases.

The committee has since 2015 decided to launch a version of the language every year in the format ES2015, ES2016, ES2017 and so on. Those features which cannot make to the current release get added to the next draft.

So today, JavaScript has a wide array of new features available, which cannot be used in production code since few browsers might not support them.

But, as is always the case, another bunch of geeks have come up with Babel which is a transpiler which can take in any version of JavaScript and emit ES5 which all modern browsers support.

I know we have covered a lot in this post. We would eventually dig deep into the basic fundamentals of the language and then eventually work our way till we know how to read new drafts and know what to expect from future versions of the language. We will also explore various libraries written for client-side (Backbone, Ember, React, Redux etc) as well as back-end execution (Express, Meteor, Kraken etc) and learn how to use a few of them to create modern fast applications which solve real-world problems.

Edits, Tips, Suggestions, Feedback? Please let me know in the comments below.

Did you find this article valuable?

Support Sunny Gupta by becoming a sponsor. Any amount is appreciated!