Articles on functional programming

Will Ockelmann-Wagner

Will Ockelmann-Wagner

A Proposal: Elixir-Style Modules in JavaScript

Moving your code towards a more functional style can have a lot of benefits – it can be easier to reason about, easier to test, more declarative, and more. One thing that sometimes comes out worse in the move to FP, though, is organization. By comparison, Object Oriented Programming classes are a pretty useful unit

Andrew Hao

Andrew Hao

Taking Elm for a Test Drive

Elm emerged on the scene in early 2012 as a strongly-typed, functional language that compiles down to Javascript. With its architecture and type system, it claims to provide bulletproof guardrails to help developers build systems that are highly reliable, with “no runtime exceptions in practice”. Elm prides itself on having a low barrier of entry

Erin Swenson-Healey

Erin Swenson-Healey

Composing Synchronous and Asynchronous Functions in JavaScript

Our example application implements a function createEmployee that is used to create an employee from a personId. To create an employee, our system loads some data from our database, validates that data, and then performs an insert. Some of our functions are written in continuation-passing style (they accept a callback) and some are written in

Erin Swenson-Healey

Erin Swenson-Healey

Gettin’ Freaky Functional w/Curried JavaScript

Partial application refers to the practice of filling in a functions parameters with arguments, deferring others to be provided at a later time. JavaScript libraries like Underscore facilitate partial function application – but the API isn’t for everyone. I, for one, feel icky sprinkling calls to _.partial and _.bind throughout my application. Curried functions (found

Erin Swenson-Healey

Erin Swenson-Healey

Tidying Up a JavaScript Application with Higher-Order Functions

Higher-order functions are functions that can do one or both of the following: Take a function or functions as arguments Return a function as an argument Most programmers by now are familiar with higher-order functions such as map, reduce, and filter. These functions abstract away the boilerplate when processing collections. For example… Given a string-capitalizing

Erin Swenson-Healey

Erin Swenson-Healey

Composing Data Pipelines: (Mostly) Stateless Web Applications in Clojure

I describe building an application in a functional style as the act of composing many smaller, context-free functions into pipelines of data transformations which map from system inputs to outputs. Compojure (a Clojure web application library similar to Bottle and Sinatra) represents this input as a simple, immutable hash map which is transformed through a

Erin Swenson-Healey

Erin Swenson-Healey

Applying Functional Programming Principles To Your Rails Codebase

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

Jared Carroll

Jared Carroll

Better Cohesion with the Type Class Pattern

Encapsulation is often called the core of object-oriented programming. Data is bundled with the functions that operate on that data. However, too much behavior can lead to monolithic, incohesive classes. The type class pattern preserves a class’s core behavior but defines orthogonal behaviors externally. Type classes allow you to “extend” both user-defined and native classes

Stripes
Jared Carroll

Jared Carroll

Partial Function Application in Haskell

Partial function application refers to calling a multiple parameter function with less than its total number of parameters. This results in a new function taking the remaining number of parameters. Simple functions created from partial function application are very useful and often require much less syntax than an anonymous function equivalent. In Haskell, partial function