BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Exploring ES6: Book Introduction and Author Interview

Exploring ES6: Book Introduction and Author Interview

This item in japanese

Bookmarks

Exploring ES6 by Axel Rauschmayer is an in-depth look at JavaScript’s latest features. This article includes a short interview with the author.

Dr. Axel Rauschmayer’s book, Exploring ES6: Upgrade to the next version of JavaScript, is a comprehensive guide to the new features introduced by ECMAScript 2015, being accompanied by code samples. The author relies on the fact that his readers are either familiar or can get up to speed on JavaScript by studying his other book, Speaking JavaScript, which covers the language in depth up to ES5.

Exploring ES6 starts with a bit of JavaScript history, its versions, the standardization body working on it, the design process, and the language’s current goals: making JavaScript a better language, more interoperable while keeping it compatible with previous versions. The author observes that Ecma has decided to keep JavaScript fully backwards-compatible to avoid “breaking the web,” asking all parties involved to continue to run old code and introducing new features that do not conflict with previous ones. The book continues by highlighting the most important JavaScript tools for ES6 transpilation (compilation) to ES5, package management, module management, linters, shims, polyfills, parsers, REPLs, and others.

After this consistent introduction, Rauschmayer starts looking into ES6’s new features, including short descriptions of these features, code samples, along with an in-depth look into them, sometimes explaining why Ecma decided to design the language in a certain way over another. Some of these features were provided before by various libraries as it is the case for classes and modules, but others are completely new, namely promises, generators or proxies. Some of the features covered by the author are (this is not an exhaustive list):

  • Data: number literals, Math methods, string methods, template literals, symbols, scoping, destructuring
  • Modularity: arrow functions, classes, modules
  • Collections: new array features, maps, sets, generators
  • Other: asynchronous programming, Unicode, proxies

The book concludes with a number of coding style tips, such as: when to use const, let, or arrow functions, avoid mixing default exports and named exports, formatting generators, and encourages using classes.

We have interviewed the author to find out his opinion on a number of related topics.

InfoQ: Unlike ES5 which is fully implemented by all major JavaScript agents, no agent has implemented all ES6 features, and the features implemented by one may have not been implemented by others. How is the web developer supposed to write in ES6 if no feature is implemented by all major agents? What do you recommend?

AR: It may take until 2016 until the first JavaScript engine supports all of ECMAScript 6. Before that, it only makes sense to compile ES6 to ES5 and to deploy that code. Starting in 2016, you can check in each engine whether it supports ES6 (or rather, those pieces of it that you are using) and then either load the native version of your code or the compiled ES5 version.

InfoQ: Based on past adoption of ES5, what is a reasonable timeframe when we would see ES6 fully adopted by the major browsers? One year? Two years? Five years?

AR: It is really hard to tell, because I don’t know the agendas of Microsoft and Apple. Microsoft still lists some core features as “under consideration” on status.modern.ie and Apple is always slightly inscrutable. But Mozilla and Google are well on their way to support ES6 completely by the end of 2015 or by early 2016.

InfoQ: How do you comment on One JavaScript? Is it better for the web rather than forcing versioning, which is coming with the promise of a cleaner language?

AR: The ES6 approach to avoiding versioning was called “One JavaScript” by David Herman. Basically, it means that ES6 is a superset of ES5. That is, ES6 is 100% backward compatible and JavaScript won’t be forked into ES5 (and earlier) and ES6 (and later). As a result, engines stay simpler and moving an ES5 code base to ES6 is easy – it is already valid ES6. The only downside of One JavaScript is that it limits you w.r.t. cleaning up the language: you can never remove features, only add new ones.

InfoQ: Are there any features that you wanted in ES6 and are not there yet? Or features that you would standardize differently?

AR: ES6 is big enough. I would have done classes slightly differently, but I’m happy that they are in ES6. A bit longer term, I’m looking forward to traits (or mixins) and a more comprehensive standard library (especially utilities for working with iterables).

InfoQ: Some book chapters are marked as not finished yet. Do you have a roadmap on their completion?

AR: I have finished all chapters that I consider most important. I’ll try to finish the remaining ones in the coming months.

Exploring ES6 is available online for free in HTML form or as PDF/ePub/MOBI for a suggested price.

ES6 was voted today by Ecma International. More details in the post, ECMAScript 2015 Has Been Approved.

Rate this Article

Adoption
Style

BT