The Past, Present, and Future of JavaScript
The Past, Present, and Future of JavaScript
and Future of
JavaScript
Where We’ve Been, Where We Are,
and What Lies Ahead
Axel Rauschmayer
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are regis-
tered trademarks of O’Reilly Media, Inc. The Past, Present, and Future of Java-
Script and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their
products are claimed as trademarks. Where those designations appear in this book,
and O’Reilly Media, Inc., was aware of a trademark claim, the designations have
been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher
and authors assume no responsibility for errors or omissions, or for damages re-
sulting from the use of the information contained herein.
ISBN: 978-1-449-33996-8
1344364583
Table of Contents
iii
The Past, Present, and Future of
JavaScript
Over recent years, JavaScript has seen an impressive rise in popularity. Initially,
that popularity was fueled by the success of client-side scripting, but JavaScript
is increasingly being used in a general-purpose capacity, e.g. to write server
and desktop applications. This article examines the JavaScript phenomenon
from three angles:
• “The Past” on page 1
• “The Present” on page 5
• “The Future” on page 6
We conclude with a wish list and a few parting thoughts.
The Past
In 1995, Netscape’s Navigator was the dominant web browser and the com-
pany decided to add interactivity to HTML pages, via a lightweight program-
ming language. They hired Brendan Eich to implement it. He finished a first
version of the language in 10 days, in May 1995. Its initial name was Mocha
which was changed to the more Netscape-esque LiveScript in September. In
December, Netscape and Sun had a licensing agreement that led to the pro-
gramming language’s final name, JavaScript. At that point, it was included in
Netscape Navigator 2.0B3.
The name “JavaScript” hints at the originally intended role for the language:
Sun’s Java was to provide the large-scale building blocks for web applications,
while JavaScript was to be the glue, connecting the blocks. Obviously, that
shared client-side responsibility never transpired: JavaScript now dominates
the browser, Java is mostly dead there.
1
JavaScript was influenced by several programming languages: The Lisp dialect
Scheme gave it its rules for variable scoping, including closures. The Self pro-
gramming language—a Smalltalk descendant—gave it prototypal inheritance
(object-based as opposed to class-based).
Because JavaScript was supposed to support Java, Netscape management de-
manded that its syntax be similar to Java’s. That ruled out using other existing
scripting languages such as Perl, Python or TCL. However, even though Java-
Script’s syntax is similar to Java’s, it is quite a different language.
[1 on page 36]
Standardization
After JavaScript came out, Microsoft implemented the same language, under
the different name JScript, in Internet Explorer 3.0 (August 1996). Netscape
decided to standardize JavaScript and asked the standards organization Ecma
International to host the standard. Work on a specification called ECMA-262
started in November 1996. The first edition of ECMA-262 came out in June
1997. Because Sun (now Oracle) had a trademark on the word Java, the lan-
guage to be standardized couldn’t be called JavaScript. Hence, the following
naming was chosen: ECMAScript is the name of the standard language, its
implementations are officially called JavaScript, JScript, etc. Naturally, when
talking unofficially about either the standard or its implementations, one
mostly uses the term JavaScript. The current version of ECMAScript is 5.1,
which means the same as ECMA-262, edition 5.1. That version has also be-
come an ISO standard: ISO/IEC 16262:2011.
ECMA-262 is managed and evolved by Ecma’s Technical Committee 39
(short: TC39). Its members are companies such as Microsoft, Mozilla, or
Google, which appoint employees to participate in committee work—three
names among several: Brendan Eich, Allen Wirfs-Brock (editor of ECMA-262)
and David Herman. TC39’s work includes discussing the design of upcoming
versions via open channels such as a mailing list.
Reaching consensus and creating a standard is not always easy, but thanks to
it, JavaScript is a truly open language, with implementations by multiple ven-
dors that are remarkably compatible. That compatibility is made possible by
a very detailed and concrete specification. For example, it often uses pseudo-
code to specify things. The specification is complemented by a test suite called
test262 that checks an ECMAScript implementation for compliance. It is in-
teresting to note that ECMAScript is not managed by the World Wide Web
Consortium (W3C). TC39 and the W3C collaborate wherever there is overlap
between JavaScript and HTML5.
"first": "Jane",
"last": "Porter",
"married": true,
"born": 1890,
Over the years, JSON has become a popular lightweight alternative to XML,
especially when structured data is to be represented and not markup. Natu-
rally, JSON is easy to consume via JavaScript.
2004—Dojo Toolkit, a framework for programming JavaScript in the
large. The Dojo Toolkit facilitates programming in the large by providing the
necessary infrastructure: an inheritance library, a module system, an API for
desktop-style graphical widgets, etc.
The Past | 3
2005—Ajax, browser-based desktop-class applications. Ajax is a collec-
tion of technologies that brings a level of interactivity to web pages that rivals
that of desktop applications. One impressive example of what can be achieved
via Ajax was introduced in February 2005: Google Maps. You were able to
pan and zoom over a map of the world, but only the content that was currently
visible was downloaded to the browser. After Google Maps came out, Jesse
James Garrett noticed that it shared certain traits with other interactive web-
sites. He called these traits “Ajax,” an acronym for Asynchronous JavaScript
and XML. The two cornerstones of Ajax are: First, loading content asynchro-
nously in the background (via XMLHttpRequest). Second, dynamically up-
dating the current page with the results (via dynamic HTML). That was a
considerable usability improvement from always performing complete page
reloads.
Ajax marked the mainstream breakthrough of JavaScript and dynamic web
applications. It is interesting to note how long that took—at that point, the
Ajax ingredients had been available for years. Since the inception of Ajax, other
data formats have become popular (JSON instead of XML), other protocols
are used (e.g., Web Sockets in addition to HTTP) and bi-directional commu-
nication is possible. But the basic techniques are still the same. However, the
term Ajax is used much less these days and has mostly been replaced by the
more comprehensive term HTML5 (JavaScript plus browser APIs).
2005—Apache CouchDB, a JavaScript-centric database. Roughly,
CouchDB is a JSON database: You feed it JSON objects, without the need to
specify a schema in advance. Additionally, you can define views and indexes
via JavaScript functions that perform map/reduce operations. Hence,
CouchDB is a very good fit for JavaScript because you can directly work with
native data. Compared to a relational database, there is no mapping-related
impedance mismatch. Compared to an object database, you avoid many com-
plications because only data is stored, not behavior. CouchDB is just one of
several similar “NoSQL” databases. Most of them have excellent JavaScript
support.
2006—jQuery, helping with DOM manipulation. The browser DOM
(Document Object Model) is one of the most painful parts of client-side web
development. jQuery made DOM manipulation fun by abstracting over
browser differences and by providing a powerful fluent-style API for querying
and modifying the DOM.
2007—WebKit becomes the foundation of the mobile web. Based on prior
work by KDE, WebKit is an HTML engine that was introduced by Apple in
2003. It was open-sourced in 2005. With the introduction of the iPhone in
2007, it became the foundation of the mobile web. WebKit is now the main
engine for Android and the only engine for iOS, and dominates the mobile
The Present
Dynamic web applications led to JavaScript’s initial popularity. The Web had
become an exciting ecosystem for applications, and you needed JavaScript to
be part of it. As outlined above, many more pieces have since been added to
the JavaScript puzzle that helped make it an appealing general-purpose lan-
guage. JavaScript programs have become fast thanks to modern JavaScript
engines. They can use JavaScript-centric databases and exchange data with
their environment (e.g. with web services) via JSON. Server-side JavaScript
allows one to use the same language for the server and for the client. Node.js
The Present | 5
also makes it possible to use JavaScript for build scripts and shell scripts.
Lastly, JavaScript is possibly the most open programming language there is:
no single party controls it, there is a well-written specification for it (whose
value cannot be overestimated), and there are several highly compatible im-
plementations available.
The Future
The future brings many exciting developments for JavaScript: ECMA-
Script.next will fix quirks and add new features. It will also be a better target
language for compilers. Support for concurrency is important and several op-
tions for JavaScript are currently being evaluated. Finally, HTML5 is becoming
a compelling platform, not just for web applications, but also for mobile ap-
plications and desktop applications.
console.log(tmp); // undefined
if (x > y) {
var tmp = x;
x = y;
y = tmp;
if (x > y) {
let tmp = x;
The Future | 7
x = y;
y = tmp;
const is similar to let, but variables declared by it can only be initialized once
and cannot be changed afterward—they are read-only. Furthermore, you get
an error if you read the variable before it has been initialized. For example:
const BUFFER_SIZE = 256;
// Rest parameters
let { x: horiz } = { x: 5, y: 3 };
console.log(horiz); // 5
Destructuring works even for parameters, which is handy if you want to have
labeled optional parameters:
// Declare
function moveBy(point, { x = 0, y = 0 }) {
...
// Call
moveBy(somePoint, { x: 2, y: 7 });
moveBy(somePoint, {});
One can also allow the object with the optional parameters to be omitted:
// Declare
function moveBy(point, { x = 0, y = 0 } = { x: 0, y: 0 }) {
...
// Call
moveBy(somePoint);
otherfunc(...args);
otherfunc.apply(null, arguments);
Arrow functions
JavaScript uses the same construct, the function, for both methods and non-
method functions. The problem with the former is that it is potentially con-
fusing to read the word function in the context of a method definition. The
problem with the latter is that you want to access the this of the surrounding
context (“lexical this“), instead of shadowing it with your own this. To work
around this limitation, one often uses a pattern such as that = this (*):
let jane = {
name: "Jane",
The Future | 9
logHello: function (friends) {
friends.forEach(function (friend) {
});
name: "Jane",
logHello(friends) { // (*)
});
An arrow function achieves lexical this via binding, so the following two
statements are roughly equivalent (bind creates two function objects, an arrow
function only a single one):
let func = (a, b) => { return this.offset + a + b }
The body of an arrow function can also be an expression, making code much
more readable. Compare:
let squares = [ 1, 2, 3 ].map(function (x) { return x * x });
},
More examples:
{ foo } // same as { foo: foo }
{ x, y } // same as { x: x, y: y }
The Future | 11
Object extension literals
With super-references, a method is much tighter bound to the object it is stored
in and needs to have a reference to it. The method definition syntax above
takes care of that and is thus the preferred way of creating methods. An object
extension literal ensures that this syntax can also be used to add methods to
an existing object. Example:
obj.{
anotherMethod(x) {
If you want to add the above method “manually,” you can’t use assignment,
you have to use the new function Object.defineMethod:
Object.defineMethod(obj, "anotherMethod", function (x) {
});
Another example:
function Point(x, y) {
this.{ x, y };
this.x = x;
this.y = y;
function Multiplier(factor) {
// Privileged method:
this.getFactor = function() {
return factor;
};
// Public method:
};
The following code is similar, but keeps the private data in the property
_factor. The name starting with an underscore marks that property as private.
The problem with this approach is that such properties occupy the same
namespace as public properties and pollute it, when they should be hidden.
And the private data is not safe from outside access.
function Multiplier(factor) {
// Private data:
this._factor = factor;
// Public method:
};
The Future | 13
The proposal “private name objects” for ECMAScript.next combines the ad-
vantages of both approaches and works as follows. Currently, property names
have to be strings. The proposal additionally allows one to use name objects
that have to be explicitly created and are unique and unforgeable:
import Name from "@name";
function Multiplier(factor) {
// Private data:
this[factorKey] = factor;
// Public method:
};
The property whose name is the name object factorKey cannot be found via
any enumeration mechanism (Object.getOwnPropertyNames(), for...in, etc.).
And one can only access its value if one has its name. Hence, there is no name-
space pollution and the private data is safe.
Class declarations
Implementing single types via constructor functions is reasonably easy in Java-
Script, but subtyping is too complicated and making super-references is
clumsy.
Right now, you have to write:
// Supertype
function Point(x, y) {
this.x = x;
this.y = y;
Point.prototype.toString = function () {
// Subtype
Point.call(this, x, y);
this.color = color;
ColorPoint.prototype = Object.create(Point.prototype);
ColorPoint.prototype.constructor = ColorPoint;
ColorPoint.prototype.toString = function () {
};
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
toString() {
// Subtype
constructor(x, y, color) {
The Future | 15
super.constructor(x, y);
this.color = color;
toString() {
Modules
JavaScript has no built-in support for modules with imports and exports. You
can implement quite powerful module systems in the language, but there are
several competing standards. The two most important ones are: Asynchronous
Module Definitions on the client side and Node.js modules (which stay very
close to the CommonJS standard) on the server side. ECMAScript.next will
provide a common module standard for the language. The following shows
the module definition syntax in action.
import 'http://json.org/modules/json2.js' as JSON;
Output:
hello
world
console.log(name);
function iterArray(arr) {
let i = -1;
return {
The Future | 17
[iterate]() { // property name is a name object
},
i++;
if (i < arr.length) {
return arr[i]
} else {
console.log(elem);
Generators
Generators are lightweight co-routines. When invoked, they create an object
that wraps a function. One can continue the evaluation of that function via
the next() method and pause the execution via the yield operator (inside the
function); yield is closely related to return and provides the value that
next() returns. A generator is produced via the keyword function* (alas, one
couldn’t use the keyword generator because that might break existing code).
Let’s take the following non-generator function iterTreeFunc and turn it into
a generator.
// Iterate over a tree of nested arrays
if (Array.isArray(tree)) {
// inner node
iterTreeFunc(tree[i], callback);
} else {
// leaf
callback(tree);
Interaction:
> iterTreeFunc([[0, 1], 2], function (x) { console.log(x) });
if (Array.isArray(tree)) {
// inner node
} else {
// leaf
yield tree;
Interaction:
> let gen = iterTree([[0, 1], 2]);
> gen.next()
The Future | 19
0
> gen.next()
> gen.next()
> gen.next()
Exception: StopIteration
As you can see, the generator object is also an iterator and can thus be iterated
over:
for (let x of iterTree([[0, 1], 2])) {
console.log(x);
try {
read("foo.json"), read("bar.json"))
.timeout(1000);
render(foo);
render(bar);
} catch (e) {
});
1000);
failure);
failure);
function success() {
cancelTimeout(tid);
render(foo);
render(bar);
function failure(e) {
if (xhr1) {
xhr1.abort();
xhr1 = null;
if (xhr2) {
xhr2.abort();
The Future | 21
xhr2 = null;
uint64 is a constructor for 64-bit unsigned integers. Not using the new operator
and the name starting with a lowercase letter are indications that value objects
are different from reference objects. Value objects are considered objects by
typeof:
typeof uint64(123) // "object"
That means that current code won’t be confused when it is confronted with a
value object. In contrast, adding new primitive types to the language would
likely cause more problems. For ECMAScript.next, value objects will probably
only be used to introduce new number types. Later, programmers might be
able to implement their own object value types, possibly including overloaded
operators. Thanks to uint64 values being immutable and compared by value,
JavaScript engines have the option of directly working with (unboxed) 64-bit
values. That should bring considerable performance benefits to the language.
The current prototype implementation [4 on page 36] in Firefox gives you
just uint64 (unsigned 64-bit integers) and int64 (signed 64-bit integers), plus
properly working operators (+, *, etc.). There are also literals such as -123L for
int64(-123).
130L
Binary data
JavaScript is increasingly used in areas where it has to process binary data as
efficiently as possible. Examples: handle network protocols, decode video, in-
teroperate with native APIs and processors, and encode and decode various
serialization formats. In order to support these use cases, there is a proposal
for binary data types:
const Point = new StructType({ x: uint32, y: uint32 });
{ x: 0, y: 3 }, { x: 0, y: 3 }, { x: 0, y: 3 }
]);
Point and Triangle are binary data types, and can be used to parse and generate
binary data.
The actual handler invocation is a bit more complex. Among other things, it
allows the handler to make the distinction between the static parts (such as
"Hello") and the dynamic parts (such as firstName). Some handlers benefit
from caching the former, e.g. when the same invocation is made multiple times
in a loop.
A few usage examples:
Raw strings: string literals with multiple lines of text and no interpretation
of escaped characters.
let str = raw`This is a text
The Future | 23
with multiple lines.
\n is not a newline.`;
By omitting the handler name, the above code invokes a default handler. In
Node.js, the same command would be written as
alert(util.format("Error: expected %s, but got %s", expected, actual));
number ${visitorNumber}:d!`);
Above, the static parts are used to look up a translation to the currently used
language. The dynamic parts are inserted into the result, possibly after having
been reordered. The marker :d indicates that visitorNumber should be dis-
played with a locale-specific decimal separator (English 1,300 versus German
1.300).
Templates:
let myTmpl = tmpl`
<h1>${{title}}</h1>
${{content}}
`;
Proxies
Proxies allow you to put a handler “in front of” an object to intercept opera-
tions applied to it. Given the following definitions:
// target points to an object
Operations on child that are passed on to the prototype proxy obviously still
trigger handler method invocations:
child["foo"] → handler.get(target, "foo", child)
One application of this is to turn a proxy into a sentinel for methods that don’t
exist:
let handler = {
};
The Future | 25
let proxy = Proxy({}, handler);
$ obj.foo(1, 2)
undefined
Collections
JavaScript does not have proper collection types. Hence, people often use ob-
jects as maps from strings to values and as sets of strings. But using them
correctly in this role is difficult. ECMAScript.next will provide three collection
types: Map, Set and WeakMap. Maps can have arbitrary keys (not just strings) and
are used as follows:
let map = new Map();
map.set("true", 2);
map.set(obj, 3);
console.log(map.get(true)); // 1
console.log(map.get("true")); // 2
console.log(map.get(obj)); // 3
console.log(map.has(obj)); // true
console.log(map.has({})); // false
console.log(map.has(obj)); // false
set.add("hello");
console.log(set.has("hello")); // true
console.log(set.has("world")); // false
A weak map is a map that holds objects without preventing them from being
garbage-collected: Neither keys nor values are held strongly — if they are only
referenced by weak maps, then they will be disposed of. Furthermore, one
cannot iterate over keys, values or entries of weak maps. You must have a key
in order to get to a value. That enables security applications where secrets are
kept in a shared data structure. One use case is to hold instance-private data
in a shared global weak map. The keys of the weak map are the instances; the
values are objects with the private data. If an instance is garbage-collected, the
associated private data will be disposed of, too.
API improvements
Several smaller improvements of the standard library have been proposed.
Some of them provide new functionality:
> "abc".repeat(3)
'abcabcabc'
> "abc".startsWith("ab")
true
> "abc".endsWith("bc")
true
[ 1, 2, 3 ]
> Array.of(3)
[ 3 ]
The Future | 27
> Number.isNaN("abc")
false
[ 1, 2, 3 ]
[ , , ]
true
console.log(start);
Under current JavaScript, the stack grows with each tail call. But that is un-
necessary because the call does not need to go back to its call site (e.g. to return
a value). Most functional programming languages avoid stack growth in such
cases. There is a proposal that would allow JavaScript engines to do the same.
Naturally, that would make JavaScript a more appealing compilation target
for functional languages.
More useful features:
• Improved support for binary data avoids compiler writers being limited
by JavaScript’s built-in types.
The Future | 29
• Data parallelism (similar to the River Trail approach described above) is
being discussed for Harmony (post ECMAScript.next).
Concurrency
For a long time, computing speed increases came from faster processor cores.
But the rate of those increases has slowed down. Further speed improvements
must come from using more cores, in parallel. Therefore, if a programming
language is to be general purpose, it must support concurrency. Such support
is difficult to get right, but several promising approaches have been proposed
for JavaScript.
Web Workers [5 on page 36] are the current weapon of choice for concur-
rent computation in JavaScript. All modern browsers support it and so does
Node.js. A worker is JavaScript code that runs in a new operating system thread
and has limited access to its environment (e.g., it can’t access the browser’s
DOM). Workers and the main thread can only communicate by sending sim-
ple messages, either strings or JSON data. All of these limitations make work-
ers a robust mechanism—one is relatively safe from concurrency problems
such as deadlocks. The following code shows how the main thread starts a
worker, waits for messages via a “message” listener, and sends a message to
the worker (the string "Hello worker!").
var worker = new Worker('worker_code.js');
};
worker.postMessage("Hello worker!");
};
self.postMessage("Hello main!");
Normal JavaScript code runs in the same thread as the user interface. Thus,
executing long-running operations in the background via a worker keeps the
UI responsive. If a worker needs more threads, it has the option to start new
workers, so-called subworkers.
console.log(String(squares)); // [1, 4, 9]
});
The current River Trail prototype is an extension for Firefox. To distribute the
work, it uses OpenCL, which must be installed on the operating system.
Conveniently, one has the option of using a sequential implementation of
ParallelArray, in pure JavaScript, if River Trail is not installed.
The Future | 31
Writing Non-Web Applications in JavaScript
HTML5 is slowly becoming a complete layer for writing full-featured cross-
platform applications. Similar to, say, the Java platform.
Mobile apps: PhoneGap—PhoneGap is a project that allows you to write
mobile apps in HTML5. Those apps will run on seven platforms: iOS (iPhone,
iPod touch), Android, Blackberry, webOS, Windows Phone, Symbian, and
Bada. Apart from HTML5 APIs, there are also PhoneGap-specific APIs for
accessing native features such as accelerometer, camera and contacts. Given
how well web technologies are supported by mobile platforms these days,
HTML5 has become the best choice for writing cross-platform mobile apps.
PhoneGap allows you to deploy those apps natively.
Desktop apps: Mozilla’s Open Web Apps project—The most interesting
aspect of this project is that it supports desktop operating systems: It lets you
install a web application as a native application on Windows, Mac OS and
Android. Such an application is run via the Firefox code, but in its own process.
That is, it looks and feels like a separate application. It also has its own profile
(preferences, cookies, history, etc.) and its windows don’t have browser
chrome. For example, there is no address bar.
These two efforts are complemented by the WebAPI project, which is about
making more native capabilities available via HTML5 APIs. Examples:
• WebTelephony: Answer and place phone calls.
• Camera API: Access a built-in camera for recording photos and live video.
Part of WebRTC, where it is needed for video conferencing.
• WiFi Information API: Detect available WiFi networks, find out their sig-
nal strength, the name of the currently connected network, etc.
• Contacts API: Read and modify a device’s native address book.
All previous solutions hosted HTML5 on top of a native layer. But there are
also operating systems where HTML5 is the native layer (or at least very tightly
integrated with it). Examples:
• 2009: The GUI layer of the Palm webOS (now Open webOS) is based on
HTML.
• 2009: Google’s Chrome/Chromium OS could be called a “browser oper-
ating system.”
• 2011: Microsoft’s Windows 8 makes JavaScript a first-class language.
Several important applications are written in JavaScript, such as the native
application store and the email program.
A JavaScript Wishlist
While many interesting JavaScript-related projects are underway, there are still
a few things that are missing. This section describes those things.
A good integrated development environment (IDE). The thing I miss most
in JavaScript, coming from Java, is a good IDE. Several already exist, but none
of them work nearly as well for JavaScript as, say, Eclipse does for Java (to be
fair, they are constantly being improved and writing an IDE for a language
takes time). One piece of the IDE puzzle is to automatically compute type
information (e.g. which types the parameters of a function normally have), via
type inference. New type inference approaches are currently being experimen-
ted with. Hopefully, class declarations will eliminate the multitude of inheri-
tance libraries that JavaScript currently has, which would help here. After EC-
MAScript.next, two proposals might be accepted that would be equally help-
ful. First, guards allow one to annotate variable declarations, parameter dec-
larations, function results and property definitions. The annotations enforce
user-defined invariants, including types. Three examples from the proposal:
let x :: Number = 37;
A JavaScript Wishlist | 33
A merging of the browser platform and Node.js. Currently, the two Java-
Script platforms browser and Node.js diverge in two ways: They use different
module systems and their APIs are different. The former difference will be
eliminated via ECMAScript.next’s common module system. The latter is es-
pecially unfortunate because more and more HTML5-based applications are
written for native deployment, which has more in common with a server-side
environment than with a client-side environment. Node.js has the highly useful
Node Package Manager (npm) and its vibrant community. Many of the npm
packages would be just as useful in a browser. Yes, there are differences, but
I don’t see why they couldn’t be abstracted over.
Facilitating the upgrade to ECMAScript.next. Handling language versions
is much more complicated on the web than for traditional languages, which
are explicitly installed on desktop and server systems by their administrators.
Challenges include:
1. New language versions must not break existing code: When language
implementers introduce a new JavaScript version, it is always a forced
upgrade for language users. Hence, it must never break existing code.
With non-web languages, that mandate is less strict because one only up-
grades if one is ready. For major upgrades, it is quite common that break-
ing changes are introduced.
2. New code won’t run on all browsers: When language users switch to a
new version, they have no control over the version that is supported by
the engines that their code will run on.
What is the best way to tackle challenge No. 1? One could prefix each piece
of code with a pragma (a meta-statement) indicating the language version. The
obvious advantage is that that would give one a lot of freedom to clean up the
language. But there is also a considerable downside. It would be cumbersome
to use, as code can appear in many places on an HTML page: code loaded from
the network, code in script tags, and code in HTML attributes. In some cases,
there are only small snippets of code. JavaScript programmers clearly aren’t
fond of this approach, as the limited adoption of ECMAScript 5’s strict mode
has shown. Furthermore, it would split JavaScript into two different dialects
(say, ECMAScript 5 and ECMAScript 6) that would further diverge over time.
Instead, TC39 took an approach called “One JavaScript.” It introduces mod-
ules as a new syntactic context where one can use a cleaned-up version of
JavaScript. Those clean-ups are breaking changes, but they are minor: some
old features are dropped; some previously legal (but questionable) practices
cause errors. Apart from that, all new features only add to the language and
can be used everywhere. As a result, code that only uses new features and best
A JavaScript Wishlist | 35
Conclusion
JavaScript is a versatile and flexible language. It is constantly being used in
new areas, due to its appeal as a language that is both widely known and
completely open (open standard, open implementations). I am still seeing
much hostility toward JavaScript, mainly due to two reasons: First, some con-
cepts (such as prototypal inheritance) are unusual. Second, it has quirks. In
both cases, the answer is educating people. They need to keep an open mind
about unusual features and learn patterns to work around the quirks. Prime
example: simulating block-scoping via immediately-invoked function expres-
sions. The current version, ECMAScript 5, will stay with us for a while. Its
current market share is roughly 50%. Wirfs-Brock estimates
[10 on page 37] that it will become the baseline for JavaScript applications
by mid 2013 and remain so for 5 years.
ECMAScript.next, the next version of JavaScript, takes on the difficult task of
fixing the quirks and introducing new features, while remaining backward
compatible. Therefore, there will always be some rough edges, but we’ll still
get a powerful and much less quirky language. Hence, these are good times to
be or become a JavaScript programmer. The ecosystem is already thriving, yet
barely getting started.
References
The following are references and sources for this article:
• [1] “The A-Z of Programming Languages: JavaScript” by Naomi Hamilton
for Computerworld.
• [2] “Harmony”, ECMAScript Wiki.
• [3] Draft Specification for ECMAScript.next (Ecma-262 Edition 6)
• [4] Firefox bug 749786 — prototype int64/uint64 value objects, with
operators and literal syntax
• [5] “Using web workers”, Mozilla Development Network.
• [6] “WebCL — Heterogeneous parallel computing in HTML5 web brows-
ers”, The Khronos Group Inc.
• [7] OpenCL Programming Guide for Mac OS X: OpenCL Overview
• [8] Project “River Trail” by Intel Labs
• [9] “The JavaScript World Domination Plan at 16 Years”, Brendan Eich.
Presentation on InfoQ.
References | 37
About the Author
Dr. Axel Rauschmayer is a consultant and trainer for JavaScript, web tech-
nologies, and information management. He has been programming since
1985, developing web applications since 1995, and held his first talk on Ajax
in 2006. In 1999, he was technical manager at an Internet startup that later
expanded internationally.