Imperative vs. Functional Programming, Blue Collars vs. White Collars

Most attempts at explaining Functional programming, that I come across, somehow remain in the math realms, which keeps it inaccessible to beginners. I have a really simple view on Imperative programming vs. Functional programming (FP), it’s akin to Blue Collar Workers vs. White Collar Workers.

Blue Collars are told what to do, not trusted with initiative. They are given very detailed instructions. They do just what they’re told, although some may be much more capable if they were empowered. That’s what’s going on with Imperative programming.

White Collars are given goals, told the intents, given resources and empowered to use their best judgment. That’s somewhat the aim with Functional programming, tell the tooling your intents and trust that it will do the right thing.

Functional programming has its root in academia, working on formal theories of program correctness. The concepts and terminology used in such academic work is still what people use in their writing and teaching. Arguably, most people write programs to solve problems, rarely do they think about writing proofs (a common expression used by FP advocates). I write a program to perform a task, I don’t write proofs, I am not doing a correctness study of any kind. This impedence mismatch doesn’t get stated often enough, but it’s quite pertinent.

Imperative Programming is not intrinsically wrong. It has served well and brought us the vaste majority of programs that we rely on, daily. It continues to be extremely useful, by far and wide the most prevalent approach. There probably always will be tasks which are only suitable to the imperative approach. For this reason, I am not too enamoured with advocacy that slams imperative programming as something to be ashamed of.

With computing, tooling and methods have become much too smart for people to keep giving excruciatingly detailed instructions. Even as we do, we can make countless preventable mistakes, fail to signal the correct intents, through misinterpretations we can induce our programs to undesired outcomes. This is largely a missed opportunity. We are entering an even more powerful phase, where humans may slowly begin to lose control of what is possible. The mental model afforded by functional programming, is much more amenable to expressing intents and constraints.

This short post is a tiny drop in the vast ocean of discourse on the subject.

Leave a Reply

Your email address will not be published. Required fields are marked *