A friend asks a harmless question and I ramble for 30 minutes.
People talk about functional programming in the same way people talk about hallucinogens. like FP is “such a beautiful experience” and “will totally expand your mind”. A friend just semi-jokingly told me he’s
gonna smoke some functional programming and play some jazz
Why Functional Programming?
There’s a sentiment that functional programming folks have: With functional programming you “discover” and not “invent”. While the veracity of this notion is dubious, I think this purported beauty can be explained as a byproduct of the processes we go through when building a program in a language like Haskell. A large example of this, by definition, would be denotational design, while a smaller one would be something like \(\eta\) reduction. The latter proposition, i.e., “it will totally expand your mind” is the math bit. Abstraction and generalization are totally lost in object-oriented land. Lawvere and Awodey after him wanted to supplant set theory as the foundation of mathematics with category theory and (a specific) type theory respectively because they saw that there existed higher order abstractions that corresponded to adjacent fields! When you’re doing FP, you’re using the fruits of their labor, which you can’t say about something as parochial as OO.
Also, it should be said, someone with less of an interest in the why
/ how does not necessarily preclude them from having the
experience when building practical things in a language like
Haskell. In fact, I see it happen all the time. However, I think in
the FP cabal, lots of folks arrive here precisely because they’re
interested in the origins of their tools.
As we progress, things get more tenuous
Personally, functional programming and its mathematical roots and adjacencies are what spurred my interests in philosophy. These interests are very focussed, and were precipitated by continuing to ask, “but why?” which brought me all the way back to Frege / Kant / Quine which seems to be an origination point for lots of cool shit. Including linguistics, which is cool as hell. I finally have the right prescription to where I can squint and see why there are so many categorical analogues to computational linguistics.
Obligatory David Foster Wallace Reference
There’s this amazing interview with DFW where he talks about “chasing the click” and how he felt said click when doing formal logic, but never like he did when writing fiction. To borrow his turn of phrase, with FP (and its adjacencies), I get to “clicking like a fucking Geiger counter”.
A Conclusion Is In Sight
Here’s what it is: It’s because functional programming is an end to itself and not a means to one. You’re free to exercise your ridiculous ideas like type-level state machines, “because you can”, not so you can Make a Webapp For Business. And, at least Haskell, was borne out of this ethos.
I’m overdoing it now, aren’t I?
Goes back to his corner of the lambda cube.