Skip to content

Beyond the Callback: Yield Control with Javascript Generators

Photo of Michael Bradley
Hosted By
Michael B.
Beyond the Callback: Yield Control with Javascript Generators

Details

Meetup starts at 6:30pm, with 30 minutes of social time. Beginning at 7pm, Darren Cruse (https://github.com/darrencruse) will present Beyond the Callback: Yield Control with Javascript Generators.

“A big part of JavaScript programming is its single-threaded control flow that never blocks. The result is that programs are written in ‘continuation passing style’ (http://matt.might.net/articles/by-example-continuation-passing-style/) where functions don’t return values, they ‘call back’ instead.

“Functions can return promises (https://www.promisejs.org/), but promises themselves resolve through callbacks... so the non-blocking control flow remains. Generators are about to change that!

“Generators (http://en.wikipedia.org/wiki/Generator_%28computer_programming%29#ECMAScript) were designed for iterating over infinite sequences of items, but they can also be used for writing code that 'appears to block’ (while remaining single-threaded). This restores the usefulness of simple functions, which take arguments and return values.

“This talk will explore these ideas in depth, explain what generators are and how they work, and survey some ‘polyfill’ (http://en.wikipedia.org/wiki/Polyfill) libraries that use them to provide ‘pseudo blocking’ control flow. I will also look at the ES7 async/await (https://github.com/lukehoban/ecmascript-asyncawait) proposal (similar functionality – different syntax), and consider how generators can be used today. Lastly, I'll look at what (if any) performance costs come from using generators.

“By the end, I hope you will come away with an understanding of what generators are and how they can be useful to you as a JavaScript developer, and that you will have the confidence to pick up and use a generators library.”

-------

Starting about 8:30pm, we'll move into a hacking session to experiment with the material that's been presented, and with JavaScript and Node.js in general.

Sovereign Technologies will be providing complementary pizza and beverages, so come hungry, come thirsty, bring your laptop and be ready to code!

Photo of STL JS group
STL JS
See more events
Asynchrony
900 Spruce St #700, St. Louis, MO · Saint Louis, MO