Categories


Archives


Recent Posts


Categories


More Async Javascript/Event Loop Stuff

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

If you liked the video from the last quickies post you may also enjoy Asynchrony: Under the Hood, a talk from @codebytere that covers similar territory. The presentation style is a bit more formal, but that suits the density of the information being transmitted. You get the event loop, the microtask queue, and an overview of generators and async/await in circa 2018 javascript.

This was the first I’d heard of Javascript’s microtask queue, which lead to my discovery of this Tasks, microtasks, queues and schedules article, which covers the behavior of said queue in browsers circa August 2015. My current understanding of the microtask queue is it’s a second queue of jobs that will run after a single tick of the event loop, and will empty out completely before the next tick of the event loop (vs. running one job per tick). Its main purpose seems to be wrangling the promise of javascript’s Promises API.

The attention that software engineering, as a profession, is paying to these sorts of async programming concepts is laudable, but for information systems programming I think PHP got it right: Don’t give end-users programmers access to complex threading or async APIs, and don’t make them them think too hard about an async model. Let the asynchronous aspects be handled by the systems running the code itself.

Copyright © Alan Storm 1975 – 2019 All Rights Reserved

Originally Posted: 11th March 2019