The A-Z of programming languages: JavaScript

Computerworld Australia is undertaking a series of investigations into the most widely used programming languages. Previously we have spoken to Alfred v. Aho of AWK fame, S. Tucker Taft on the Ada 1995 and 2005 revisions, Microsoft about its server-side script engine ASP, Chet Ramey about his experience maintaining Bash, Bjarne Stroustrup of C++ fame, to Charles H. Moore about the design and development of Forth, a chat with the irreverent Don Woods about the development and uses of INTERCAL, Stephen C. Johnson on YACC, Modula-3 design committee member, Luca Cardelli about Modula-3 and Walter Bright about D.

In this interview we chat to Brendan Eich, creator of JavaScript and Chief Technology Officer of Mozilla Corp. Eich details the development of JS from its inception at Netscape in 1995, and comments on its continued popularity as well as what he believes will be the future of client-side scripting languages on the Web.

Please note that we are no longer following exact alphabetical order for this series, due to popular demand. If you'd like to submit any suggestions for programming languages or language authors that you'd like to see covered, please email

What prompted the development of JavaScript? I've written about the early history on my blog.

I joined Netscape on 4 April 1995, with the goal of embedding the Scheme programming language, or something like it, into Netscape's browser. But due to requisition scarcity, I was hired into the Netscape server group, which was responsible for the Web server and proxy products. I worked for a month on next-generation HTTP design, but by May I switched back to the group I'd been recruited to join, the client (browser) team, and I immediately started prototyping what became JavaScript.

The impetus was the belief on the part of at least Marc Andreessen and myself, along with Bill Joy of Sun, that HTML needed a "scripting language," a programming language that was easy to use by amateurs and novices, where the code could be written directly in source form as part of the Web page markup. We aimed to provide a "glue language" for the Web designers and part-time programmers who were building Web content from components such as images, plug-ins and Java applets. We saw Java as the "component language" used by higher-priced programmers, where the glue programmers -- the Web page designers -- would assemble components and automate their interactions using JS.

In this sense, JS was analogous to Visual Basic, and Java to C++, in Microsoft's programming language family used on Windows and in its applications. This division of labor across the programming pyramid fosters greater innovation than alternatives that require all programmers to use the "real" programming language (Java or C++) instead of the "little" scripting language.

So was there a particular problem you were trying to solve? The lack of programmability of Web pages made them static, text-heavy, with at best images in tables or floating on the right or left. With a scripting language like JS that could touch elements of the page, change their properties and respond to events, we envisioned a much livelier Web consisting of pages that acted more like applications.

Indeed, some early adopters, even in late 1995 (Netscape 2's beta period), built advanced Web apps using JS and frames in framesets, prefiguring the "Ajax" or "Web 2.0" style of development. But machines were slower then, JS had a relatively impoverished initial set of browser APIs and the means to communicate with servers generally involved reloading whole Web pages.

How did JavaScript get its name given that it's essentially unrelated to the Java programming language? See my blog post.

Why was JS originally named Mocha and then LiveScript? Mocha was Marc Andreessen's code name, but Netscape marketing saw potential trademark conflicts and did not prefer it on other grounds. They had a "live" meme going in their naming (LiveWire, LiveScript, etc.). But the Java momentum of the time (1995 to1996) swept these before it.

How does JavaScript differ from ECMAScript? ECMA-262 Edition 3 is the latest ECMAScript standard. Edition 1 was based on my work at Netscape, combined with Microsoft's reverse-engineering of it (called JScript) in IE, along with a few other workalikes from Borland and a few other companies.

The Third Edition explicitly allows many kinds of extensions in its Chapter 16, and so JavaScript means more than just what is in the standard, and the language is evolving ahead of the standard in implementations such as Mozilla's SpiderMonkey and Rhino engines. (SpiderMonkey is the JS engine in Firefox.)

The ECMA standard codifies just the core language, not the DOM [Document Object Model], and many people think of the DOM as "JavaScript".

Do you believe that the terms JavaScript and JScript can or should be used interchangeably? JScript is not used much or at all in cross-browser documentation and books to refer to the language. JavaScript (JS for short) is what all the books use in their titles, what all the developer docs and conferences use, etc. It's the true name, for better and worse.

Were there any particularly hard/annoying problems you had to overcome in the development of the language? Yes, mainly the incredibly short development cycle to prove the concept, after which the language design was frozen by necessity. I spent about 10 days in May 1995 developing the interpreter, including the built-in objects except for the Date class. (Ken Smith of Netscape helped write that by translating Java's java.util.Date class to C, unintentionally inheriting java.util.Date's Y2K bugs in the process!)

I spent the rest of 1995 embedding this engine in the Netscape browser and creating what has become known as the "DOM," specifically the "DOM level 0:" APIs from JS to control windows, documents, forms, links, images, etc., and to respond to events and run code from timers.

I was the lone JS developer at Netscape until mid-1996.

What is the most interesting program that you've seen written with JavaScript? TIBET was an early, ambitious framework modeled on Smalltalk.

There are amazing things in JS nowadays, including HotRuby (see for more -- this runs Ruby bytecode entirely in JS in the browser) and a Java virtual machine (see Beware: I'm not sure how much of the Java VM is implemented in JS -- still, it's by all accounts an impressive feat.

We are seeing more games, both new and ported from other implementations, as well.

And John Resig's port of the Processing visualization language takes the cake.

And what's the worst? I couldn't possibly pick one single worst JS program. I'll simply say that in the old days, JS was mainly used for annoyances such as pop-up windows, status bar scrolling text, etc. Good thing browsers such as Firefox evolved user controls, with sane defaults, for these pests. Netscape should have had such options in the first place.

Have you ever seen the language used in a way that was not originally intended? If so, what was it? And did it or didn't it work? The Java VM (Orto) mentioned above is one example. I did not intend JS to be a "target" language for compilers such as Google Web Toolkit (GWT) or (before GWT) HaXe and similar such code generators, which take a different source language and produce JS as the "object" or "target" executable language.

The code-generator approach uses JS as a "safe" mid-level intermediate language between a high-level source language written on the server side, and the optimized C or C++ code in the browser that implements JS. This stresses different performance paths in the JS engine code, and potentially causes people to push for features in the ECMA standard that are not appropriate for most human coders.

JS code generation by compilers and runtimes that use a different source language does seem to be "working", in the sense that JS performance is good enough and getting better, and everyone wants to maximize "reach" by targeting JS in the browser. But most JS is hand-coded, and I expect it will remain so for a long time.

It seems that many cross-site scripting exploits involve JavaScript. How do you feel about this? Are there plans to solve some of these problems? Yes, we have plans to address these, both through the standards bodies including the W3C, and through content restrictions that Web developers can impose at a fine grain. (See this document and the Mozilla bug-tracking work to implement these restrictions.)

When do you expect the next version of JavaScript to be released? Do you have in mind any improvements that will be incorporated? I expect the 3.1 edition of the ECMA-262 standard will be done by the middle of 2009, and I hope that a harmonized Fourth Edition will follow within a year. It's more important to me (and I believe to almost everyone on the committee) that new editions of the specification be proven by multiple interoperating prototype implementations, than the specs be rushed to de-jure approval by a certain date. But the 3.1 effort seems achievable in the near term, and a harmonized major Fourth Edition should be achievable as a compatible successor in a year or two.

The improvements in the 3.1 effort focus on bug fixes, de-facto standards developed in engines such as SpiderMonkey (e.g. getters and setters) and reverse-engineered in other browsers, and affordances for defining objects and properties with greater integrity (objects that can't be extended, properties that can't be overwritten, etc.).

The improvements for the harmonized major edition following 3.1 simply build on the 3.1 additions and focus on usability (including new syntax), modularity, further integrity features and, in general, solutions to "programming in the large" problems in the current language.

How do you feel about the place of JavaScript in Web 2.0? It's clear JS was essential to the "Ajax" or "Web 2.0" revolution. I would say Firefox, Safari and renewed browser competition, and the renewed Web standards activities they spawned, were also important.

But JS had to be sufficiently capable as a precondition for all of this progress to occur, even in the older Internet Explorer browser versions (IE5.5, IE6), which were barely maintained by Microsoft for the first five years of the new millennium. So JS was the tap root.

How do you feel about all the negative vibes expressed towards JavaScript over the years? These "vibes" seem to me to be a mix of:

  • Early objections to the idea of a scripting language embedded in HTML.
  • Appropriate rejection of the annoyance features JS enabled (and lack of sane controls, e.g. over pop-ups, until browsers such as Firefox came along).
  • Confusion of DOM incompatibilities among browsers, which caused developer pain, with the generally more compatible JS implementations, which caused much less (but non-zero) pain.
  • And of course, some people still feel negatively about the Netscape marketing scam of naming the language JavaScript, implying a connection with Java, if not intentionally sowing confusion between JS and Java (for the record, I don't believe anyone at Netscape intended to sow such confusion).

These negative vibes are understandable. JS is the only example of a programming language that must interoperate at Web scale (wider than any other platform), on multiple operating systems and in many competing browsers. Other programming languages supported by browser plug-ins come from single vendors, who can control interoperation better by single-sourcing the implementation. Therefore JS and the DOM it controls have been a rough interoperation ride for Web developers.

It did not help that Netscape and Microsoft fought a browser war that forced premature standardization after a furious period of innovation, and which ended with way too many years of neglect of JS and other Web standards under the IE monopoly.

On the up side, many developers profess to like programming in JS, and it has experienced a true renaissance since 2004 and the advent of "Web 2.0" or "Ajax" programming.

What do you think the future impact of JavaScript and other client-side scripting languages will be on the Web? I think JavaScript will be the default, and only obligatory, programming language in browsers for a while yet. But other languages will be supported, at first in one or another browser, eventually in cross-browser standard forms. Mozilla's browsers, including Firefox, optionally support C-Python integration, but you have to build it yourself and make sure your users have the C-Python runtime. We are working on better ways to support popular languages safely, compatibly and with automated download of up-to-date runtime code.

It's clear the client side of the Web standards deserves programmability, as Marc Andreessen and I envisioned in 1995. The desktop and mobile computers of the world have plenty of cycles and storage to do useful tasks (more now than ever), without having to restrict their automation capabilities to submitting forms or sending messages to real programs running on Web servers. Real programs run in browsers too, and they are written in JS.

1 2 Page 1
Page 1 of 2
Shop Tech Products at Amazon