The Web Platform
March 7–8, 2016: Training
March 8–10, 2016: Conference
San Francisco, CA

The rise of async JavaScript

Jeremy Fairbank (Test Double)
11:15am–11:45am Wednesday, 03/09/2016
Pure Code and JavaScript Salon 12/13/14/15
Average rating: ****.
(4.38, 21 ratings)

Prerequisite knowledge

Attendees should be familiar with ES6 code and the ES6 Promise and its API and have experience working with asynchronous code in JavaScript.

Description

Jeremy Fairbank explores the new async function declarations in ES7. He briefly reviews the history of asynchronous control flow mechanisms in JavaScript before making a case for the usefulness of async functions.

Asynchronous programming is a crucial part of JavaScript but has also proved a great challenge. In the beginning, we managed it with callbacks, which unfortunately led to callback hell. Next, we gained Promises, which untangled the nested callbacks and gave us powerful mapping constructs over eventual values. However, even with Promises, it was difficult to express meaningful, readable control flow and manage errors. Ultimately, to manage asynchronous JavaScript, we’ve had to create our own semantics apart from natural language constructs, such as error-object-first callbacks in Node.

Jeremy’s goal is to not only introduce async functions, but also investigate their use cases and demonstrate why they matter. One immediate benefit, for instance, is the ability to write asynchronous code in a synchronous manner, which means that we regain control of natural language constructs such as for loops and try/catch blocks with asynchronous code.

Jeremy will cover the await operator, dissect an async function to determine what is semantically happening under the hood of a JavaScript engine or in transpiled code, prove that async functions always return Promises, and identify the differences between—and performance implications of—sequential and parallel XHR requests with await.

Photo of Jeremy Fairbank

Jeremy Fairbank

Test Double

Jeremy Fairbank is a web developer at Test Double, where he helps improve how the world builds software. Jeremy has many years of experience in frontend and full stack development and has presented numerous times on web development at conferences such as Fluent Conf and RailsConf. He is passionate about frontend development and its future, especially in functional JavaScript and Elm, and is currently authoring a book on Elm with the Pragmatic Programmers. He holds a master’s degree in computer science.