We’re programmers, you and I. We are time-served, battle-hardened veterans. We have honed our objects, learned our digital ropes, intoned the Laws of Liskov and Uncle Bob, and we’re now pretty good at what we do.
And now I want you to stop what you’re doing. I want you to give up all that programming that you know and love, and I want you to do something else.
Look at your IDE. Look at the menus and buttons and hierarchical whatchamacallits and text-filled panes. You know, because you’re a sophisticated developer that none of that is real – it’s all just an appearance of reality, pixel-thin and brought to life by the operation of the software. That’s what software does: it creates the illusion of reality, and we developers: we’re magicians, summoning the appearance of reality out of nothing at all.
The tools of our trade, the incantations that create those illusions, are objects. We are trained to think in objects – hands up anyone who wouldn’t claim to be an expert in object-orientation! – and yet there is nowhere in the executing machine code, nowhere on the chip surface where those objects reside. The objects that we use to construct our illusions are themselves illusions summoned by the same process. We are seduced by our own glamours.
Deep down, deep in the machinery of the universe, there are some fundamental laws and constructs from which computer ideation is constructed, but objects are not among them. Objects are, in fact, as contingent and as arbitrary and as conventional as the depictions of the controls on our applications – no more fundamental or senior than Windows’ widgets are senior to Apple’s alternatives. Objects are not fundamental units of computation: they’re not even necessary. They’re just the approach we happen to take.
But, let’s stray even further from familiar territory. Functional programming does without objects, or procedures, or even variables of any kind. Functional programs don’t do anything, they are things. They are closer to the software-magical idea of illusion than objects (and they’re much closer to the mathematical concept of computation). Functional languages put you more closely in touch with your task and with your user. They’re simply a better way to program.
This is a strange and foreign place, where nothing ever happens, and yet everything happens at once. It’s a place where hard things become simple, and simple things are trivialised out of existence, but some trivial things turn out to be impossible.
Functions, too, are illusions, created by carefully-crafted software operating inside the machinery. But they’re a very different illusion to objects, and nothing you’ve learned in a lifetime of object-orientation will prepare you for this.
So, I’m asking you to give up programming – or at least everything you have learned about programming and believe is true. I want you to give functions a go.