Notes from Erin Swenson-Healey

Hanging up on Callbacks: Generators in ECMAScript 6

By on in Development

I hear people whine about asynchronous callbacks in JavaScript constantly. I admit that wrapping your head around control flow in the World of JavaScript (also known as “Callback Hell” or the “The Pyramid of Doom” by aforementioned whiners) can be a bit of a mind-explosion if you’re used to a top-down, synchronous programming style. “Just deal with it” has been my go-to response; after all, do we expect programming in all languages to look and feel the same? Of course not.

This all changed after a recent review of the the ECMAScript 6 Draft, which describes generators – a language feature that will greatly change the way we write both server and client-side JavaScript. With generators, we can transform nested callbacks into easy-to-read top down-style code without blocking our single event loop thread. Continue reading …

The JavaScript Event Loop: Explained

By on in Development, JavaScript

What’s this post about?

With JavaScript approaching near-ubiquity as the scripting language of the web browser, it benefits you to have a basic understanding of its event-driven interaction model and how it differs from the request-response model typically found in languages like Ruby, Python, and Java. In this post, I’ll explain some core concepts of the JavaScript concurrency model, including its event loop and message queue in hopes of improving your understanding of a language you’re probably already writing but perhaps don’t fully understand.

Continue reading …

Sinatra Best Practices: Part One

By on in Development

While Sinatra’s one-file approach may work well for your one-off, smaller
application – it can quickly become a mess as you add on multiple routes,
route-handlers, helpers, and configuration. So what’s a programmer to do?

In reading Sinatra’s documentation I’ve found a few morsels that have enabled
us to split our otherwise-monolithic (I realize this term is becoming a cliché,
but given the single-file nature of Sinatra-based web-applications I feel like
it’s appropriate) applications into smaller, more manageable pieces.

Continue reading …