Functional Programming for Everyone Else

Functional programming has become a hot topic in the last few years for programmers, but non-programmers might not understand what we’re talking about. I can imagine them wondering, “Did programs not work before? Why are they suddenly ‘functional’ now?”

Earlier today, I was tweeting a bit about the challenge of explaining to family or primary school students what the big deal is all about. Even we programmers take some time to cotton on to the notion. I know I’d have to pause for a moment if someone asked me what Haskell offers over Python.

If you’re not a programmer and have been wondering what the big deal is, here’s my attempt to lay it out.


First, consider the time just before computers existed. By the 1920s, a kind of math problem called a decision problem led various people to learn how to investigate the problem solving process itself. To do this, we had to invent an idea we call computability, meaning to automate problem solving using small, reusable pieces. A couple of mathematicians tackled this idea in two different ways (though they each came to the same conclusion), and today we have two ways to think about computability as a result.

I’m partial to Alan Turing’s approach because it’s very practical. He envisioned a process that’s quite mechanical. In fact, we now call it a Turing machine, even though his machine never actually existed. It was more of a mental exercise than something he intended to build.

To solve a problem with a Turing machine, he would break a problem into a sequence of steps which would pass through the machine on an endless tape. The machine itself knew how to understand the steps on the tape, and it knew how to store information in its memory. As the steps on the tape passed through, one at a time, the machine would consult the tape and its own memory to figure out what to do. This usually meant modifying something in its memory, which in turn could affect the following step, over and over until the steps ran out. By choosing the right set of steps, when you were done, the machine’s memory would end up with the answer you needed.

Since that time, most computers and programs are based on this concept of stringing together instructions which modify values in memory to arrive at a result. Learning to program means learning a vast number of details, but much of it boils down to understanding how to break a problem into instructions to accomplish the same thing. Programs made this way would not be considered “functional.”

At the same time, another mathematician, Alonzo Church, came up with another approach called lambda calculus. At its heart, it has a lot in common with Turing’s approach: lambda calculus breaks up a problem into small parts called functions. Instead of modifying things in memory, though, the key proposition of a function is that it takes input and calculates a result—nothing more. To solve a problem this way, little functions are written to calculate small parts of the problem, which are in turn fed to other functions which do something else, and so on until you get an answer.

Lambda calculus takes a much more abstract approach, so it took longer to work out how to make programs with it. When we did, we called these programs “functional programs” because functions were so fundamental to how they worked.


Putting all this together, I think of functional programs as ones which do their jobs without stopping to take notes along the way. As a practical consequence, this implies a few odd things. The little niceties that come first nature to procedural programs—like storing values, printing out text, or doing more than one thing at once—don’t come easy to functional programs. On the other hand, functional programs allow for understanding better what a program will do, since it will do the same thing every time if its input doesn’t change.

I think both approaches have something to offer, and in fact, most programs are made with a combination of these ideas. Turing proved neither approach was better than the other. They’re just two ways of ending up at the same result. Programmers each have to decide for themselves which approach suits best—and that decision problem can’t be solved by a program yet.

On Thematic Storytelling

When I reached ninth grade, I was dumped briefly in Honors AP English, and my teacher initiated us into the secret language of symbolism in literature. Writing was (and remains) important to me, so that class made a deep impression.

It was life-changing to find that many of the things I had read or had yet to read contained hidden meaning. Throughout the next several years, my intellectual and spiritual development involved understanding layers of meaning, their connections, and their implications—not only in the stories I enjoyed reading and writing, but also on my life and my understanding of my own existence and that of God. It was the first time I realized that works of art and literature had meaningful things to say about my world and not just their own.

That class tied symbolism into overarching themes, and themes are really what I want to talk about now. Themes were like secret messages; symbolism, the vocabulary; and stories were the paper on which the messages were written. We learned about themes and symbolism with an emphasis on connections to ancient mythology, the Bible, and fatalism versus determinism. For me, this skewed the significance of thematic content above all other literary content. I took away the idea that these stories had such powerful and important existential messages to impart that all other elements of the story only were included to support them. The only way I could imagine writing a story this way was to start with the theme, which would inform everything else.

Unfortunately, that misapprehension stunted my development as a reader and writer for years after. When reading, I got too analytical. When writing, I didn’t feel creative anymore. I regarded everything besides the theme—all the descriptions, characters, suspense, drama—as fluff. I didn’t know how to start at a theme and end up back at the same place that originally inspired me to write a story, and I figured doing anything else was frivolous.

What I described about my English class—mining literature for symbolism that may or may not even be there—seems to be a rite of passage. It’s probably attractive curriculum because it reduces reading comprehension into something rather mechanistic and testable. For whatever reason, I know a lot of people who had an experience in high school like mine.

I don’t think I’m the only person for whom this approach to storytelling presented a dilemma. The problem, as I saw it, is that writers either started with a story and later artificially incorporated symbolism, or they began with the symbolism and tried to wring a story out of it.

I remember Stephen King writing about precisely this issue in his non-fiction book On Writing. King said he tended to write the story first, and if he saw the potential to develop a theme, he would elaborate on that as he wrote and rewrote, polishing the theme until it shone through. The biggest takeaway I got from On Writing is that thematic aspects of a story are sometimes already there naturally, waiting to be developed.

He’s prolific and has taken lots of approaches to writing fiction on a theme. Some of his books, especially the earlier ones, didn’t bother. It’s difficult to come away from Christine or Cujo feeling like you missed a deeper meaning.

Other books of his swung in the other direction, incorporating lots of symbolism. Insomnia is the one that stands out for me. In On Writing, King describes struggling with the amount of planning he did in that book, and it shows. It’s full of allusions, symbols, and outright literal descriptions of the protagonist defying deities and struggling against fatalism. The Waste Lands directly describes symbolism via an English class, itself makes heavy allusion to T. S. Eliot, and uses nonsensical jokes (among other things) to symbolize a world losing its coherency and sanity.

After several years, I finally realized this approach made sense when I considered themes as an element of storytelling on the same level as other elements such as setting, plot, or characterization. Any story entails decisions about how to include and involve them and to what extent.

One example which springs to mind right away is Isaac Asimov’s “The Last Question”, which contains almost no characterization whatsoever but whose plot and theme concern itself with nothing less than the nature of the universe, sweeping its entire breadth in space and time. In the same way, some stories naturally require elaborating on setting (think of worldbuilding in high-fantasy); others never allude to their setting at all.

This way of thinking about theme feels so right to me. It frees me from the problematic dilemma I described earlier, if only I apply the same kind of thinking about theme as I apply regarding, say, plot. For example, it feels natural to me to sketch out a story plot to begin with, letting each storytelling ingredient interact and complement one another, and then proceed to work out the details as I move along. The wholeness of the plot emerges as the work continues. Why can’t theme and symbolism manifest the same way? After all, it never occurred to me to let decisions about plot or setting paralyze me this way.

I also think it would be really interesting if high school English classes gave as much consideration to characterization or setting the way they do to theme. Maybe the thinking is that those things are written in an obvious way and theme is much more tied into the context and history of the writer. On the other hand, it’s easy to say that Stephen King writes about Maine because he’s from there without further examination, but does this efface a deeper conversation we could be having about why such a familiar and detailed setting makes his books work so well? If we have to read Catcher in the Rye in high school, is it more important to talk about what the ducks in winter represent, or should we be talking about what an immature hypocrite Holden is? Does Slaughterhouse-Five teach us as much about the historical destruction of Dresden as it does about how avoidable and pointless war is?

I guess my breakthrough is to realize all these questions hold equal consideration in my mind now and broadens the kinds of stories I enjoy and the way in which I appreciate them.

Announcing My Content Licensing

A couple of recent popular posts I’ve made have motivated me to license my content here on my site. This doesn’t directly affect readers. It just means that I want to disclose what others are allowed to do with what I write without asking me first.

If anybody wants to re-license anything here (for some reason), I’m open to discussing it, but I may ask for compensation. The easiest way to contact me is just by sending email to to any address at my domain (which all lands in my inbox).