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

The rise of async JavaScript

Jeremy Fairbank (Sigient)
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

Sigient

Based in Tennessee, Jeremy Fairbank is a remote web developer for Sigient with an entirely distributed team that creates amazing designs and software. He has worked on the frontend and backend extensively with React, Angular, Backbone, and Ruby on Rails. He blogs at blog.jeremyfairbank.com and has been featured in JavaScript Weekly a few times. Outside of developing, he enjoys being a husband and father and playing guitar.