Context: Browsers Get Smart
In 1993, developer Marc Andreessen helped the National Center for Supercomputing Applications at the University of Illinois to launch Mosaic: a user-friendly, graphical web browser. The Internet was evolving from being a text-based realm of hobbyists to a multimedia universe for mainstream computer users.
Andreessen subsequently founded the private Mosaic Communications Corporation and published a commercial browser called Mosaic Navigator in 1994 (the name was changed to Netscape after settling a lawsuit.) Netscape Navigator was a hit and Netscape's stellar IPO set new records.
Microsoft's reply, Internet Explorer, loomed ominously on the horizon. Andreessen knew that Navigator would have to push new features to maintain dominance; web browsers needed to move beyond displaying static documents, and run truly interactive software.
In 1995 Netscape brokered a deal with another Microsoft competitor, Sun Microsystems, which was debuting a major programming language, Java. Java borrows syntax from C / C++, but compiled Java bytecode is portable — it can run as-is on different operating systems. A user with both Navigator and the Java Virtual Machine installed could execute Java programs as standalone "applets,” contained within (but separated from) a web page.
Java's fenced-off nature meant that there was still a need for a "scripting" language to enhance the web page – animating drop-down menus, validating form entries, etc. Since Sun was positioning Java as the professional choice for complex embedded programs, this companion language was envisioned as a small approachable solution for designers and page authors. Crucially, it could be written directly inside of HTML documents and would be interpreted by the Navigator browser itself.
It was at this point in early 1995 that Brendan Eich was famously contracted by Netscape to design such a language on an extreme deadline. The requirements provided to Eich, and his decisions in fulfilling them, would end up having a disproportionately monumental effect on the nature of the web.
Designing a language is a challenge, but also an opportunity. Programming languages can express old ideas in new ways, and popularize alternative approaches.
Eich had read Structure and Interpretation of Computer Programs, a landmark MIT textbook, featuring the language Scheme, which combines a minimalist feature set with surprising power and flexibility – it does a lot with little. In Scheme, procedures can work on and generate "ordinary" data (numbers, text, etc.), as well as work on and generate other procedures, a defining characteristic of functional programming.
Netscape recruited Eich to implement "Scheme for the browser," then gave him a contradictory stipulation: whatever he came up with had to "look like Java." Eich ultimately created a quick proof of concept using Java-based syntax to express Scheme-based capabilities. He then went on to incorporate, into this already unlikely combination, a unique style of object-oriented programming (OOP).
A Unique Language
In OOP, data and procedures are encapsulated together into "objects", which are typically defined via a hierarchy of abstract classes. Java is one of the most object-oriented languages in existence, with the concept of classes inextricably woven throughout. But OOP in Java has an all-encompassing and rigid flavor that Eich eschewed. He instead chose a unique style of OOP – a dynamic and relaxed prototypal inheritance system inspired by the language Self. Objects could be created at will and linked to other objects (called prototypes). This prototypal inheritance adds comparatively little syntax to a language, yet is capable of simulating classical or alternative inheritance patterns.
This new language combined:
- Superficialities and control structures from Java
- Core functional and object-oriented behavior from Scheme and Self
- Features that were minimalist yet flexible
A New Name: ECMAScript
Java applets, meanwhile, were languishing:
- Users did not enjoy keeping the Java Virtual Machine up to date
- They were scared off by Java's security prompt
- They resented having to boot up large Java programs when visiting certain pages.
JS still lacked certain features that would normally be expected of a "big" language, though, so ECMAScript 4 sought to remedy that with myriad additions: Java-style classes and interfaces, static types with annotations, improved scoping and variable types, etc. Developers from Microsoft, Opera, Yahoo!, and Macromedia debated what direction JS should take, while spinoff languages like Macromedia's ActionScript for Flash added to the uncertainty. ES4 descended into development hell and was eventually abandoned.
ES5 (a more modest update than the ill-fated ES4, and originally named ES3.1) was released in 2009, and the Ecma community once again piled on a wishlist of new JS features for ES6. This resulted in another protracted consensus process, spanning an interminable six years, and practically doubled the size of ECMAScript.
The new system allows features to be proposed, researched, and ratified in parallel. Every year, Ecma releases whichever features are deemed ready. ES6 was officially published as ES2015, and since then, ES2016 and ES2017 have delivered only incremental changes, with continuous support from browser vendors.
- It can be learned quickly
- It enables developers to build things quickly,
- It runs quickly
- It has a subset of truly “good parts.”
JS code can now be found in phone apps, robots, space agencies, and more.
JS also has some well-known foibles:
- Entertaining type coercion surprises,
- A seemingly endless wait for a proper module system
- Coding JS well requires, as do most languages, discipline and training.
- No control over lower-level layers (e.g. memory or threads)
But the community has vigorously addressed these issues with a vibrant ecosystem of code, documentation, and educational resources.
What is jQuery: An Intro for Beginners
Should you learn jQuery? We look at the debate around jQuery and what jobs need jQuery.
What is Express? A Guide for Beginners
Git and GitHub: A Guide for Beginners
Turing School instructor David explains Git, GitHub, version control, and repositories for beginners