What is flatMap?

flatMap is a method on collections that, at a surface level, transforms each element into another collection of any type, then takes all the elements out of those collections and puts them into one. It is like a map followed by a flatten. Why do two things in one step? Conceptually, List.map is always 1:1 …

Read moreWhat is flatMap?

What makes a functional programmer?

Michael O’Church has a lot to say about the functional programming community. His post, Functional Programming is a Ghetto (in the “isolated, exclusive neighborhood” sense of ghetto) contains some great descriptions of what goes through a programmer’s head after he or she learns to think in a functional style. The following is a paraphrase of …

Read moreWhat makes a functional programmer?

Why Functional Matters: Your white board will never be the same

Why learn functional programming? For better design skills! The other day we designed a process to match cleared deposits with dispensations. This is how I would have white-boarded it a few years ago: Since then I’ve played around with functional programming. It encourages one to think about processing in terms of data streams: data comes …

Read moreWhy Functional Matters: Your white board will never be the same

Lessons from SICP: what is iterative programming?

SICP insight of the day: iterative programming doesn’t require a for loop. Tail recursion is iterative programming. It looks very close to recursion, but the distinction is: a program is iterative if everything it needs is stored in a few state variables. In an imperative style the state is stored in mutable variables. In a …

Read moreLessons from SICP: what is iterative programming?

Bring the data to the code, or the code to the data?

Object-oriented code was conceived as message-passing between objects. Service-oriented architecture emphasizes delegation to another system. The entire web is a whole bunch of requests flying around. There is one clear way to be efficient about this: stop waiting for results. When we’re writing imperative code, we want to write the operations in the order they …

Read moreBring the data to the code, or the code to the data?