Notes from Erin Swenson-Healey

Applying Functional Programming Principles To Your Rails Codebase

By on in Design, Development, Everything Else

All the programmers around me seem to have very strong opinions about functional programming. The Internet certainly loves to talk about it. Some of the concepts are interesting – but many of them (at first) don’t seem to apply for those of us writing database-fronting web applications. What can we apply from a world in which side effects are shunned if the majority of what our application is doing is getting stuff out of a database for display on a web page?

In this article, I’ll share some of the lessons I’ve learned writing programs in a functional style using other languages and how these lessons apply to problems of testability, predictability, and parallelism in the regular ‘ole web application code we’re writing today. I’ll show you how you can increase the quality of your existing application by introducing stateless functions that interact with the state-manipulating stuff you’re already familiar with (and have already written). This article is geared towards web application development in the real world; don’t fret, the word “monad” does not appear anywhere on this page. Continue reading …


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 …