September 4, 2015

Developer Spotlight: Asynchronous Javascript and Promises via Chicago Javascript and @innoarchitech

The Chicago Javascript Meetup group - otherwise called js.chi() - hosted a meetup on asynchronous Javascript (Editor's note: this is a bit of a latergram - the presentation was on August 26th, 2014). Users of Google Analytics certainly have heard the term async - asynchronous code was introduced in 2009. But what does “async" mean in general? Here’s a brief run down:

JavaScript is a single-threaded language. The phrase "single-threaded" means that invoking a long-running process blocks all execution until that process completes. Think of this as a moving up and down a ladder - you can’t really skip a rung to go down or up. Imagine that, and you have an idea of how JavaScript works. It also draws imagery of what challenges can occur: single UI elements are unresponsive, animations pause, and no other code in the app can run.

The solution to this problem is to avoid synchronous execution where possible. One way of deploying asynchronous JavaScript is to have a JavaScript function execute at a later time.  Event handlers are an example; Event handlers are invoked after another call has raised an event. Callback functions are another kind of asynchronous processing, because they call back into the code that initiated the process.

Getting back to the presentation, Alex Castrounis (@innoarchitech), a JavaScript enthusiast who runs a JavaScript resource site, Innoarchitech, asked the audience if they thought JavaScript is asynchronous? They answer was no, it is not. He goes on to note how async and promises play hand in hand in improving JavaScript functionality.

Alex then goes through the JavaScript engines that help set up the definition of promises. Promises are the result of an asynchronous results, allowing for executing multiple async calls without blocking event loops. Alex explains in detail how they are used, when to use them, and their benefits.  You can check out the slides from Alex’s presentation at Slides.com (click on the image below).

Asynchronous_ Javascript

Alex mentions some details about JavaScript engines and how they relate to promises. Engines such as Spidermonkey, chromenode.js, and V8 play into the message queue and event loop because of their components - interpreter, heap (where objects and variable reside) , and call stack. Message queues and event loops are part of the promise functionality flow.

You can see past talks and other member information posted on the Chicago Javascript group - called " js.chi()" - on their Meetup page.  The Chicago Javascript group was formed in 2008 and has been a staple of gathering the developer community around the Javascript language.

Additional information for slides and code from Alex are below:

Slides: http://slides.com/alexcastrounis/async-js-promises#/
Code: https://github.com/acastrounis/async-js-promises
Blog: http://www.innoarchitech.com/asynchronous-javascript-promises/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram