FP is for Nerds

In recent years, functional programming (or FP) has become all the rage. Proponents of FP tout its safety in writing programs that are reliable and less buggy, especially in concurrency. They say programs are more concise and compact due to very economical expression.

That may be, but it’s obvious that FP has not taken off after a great many years in the wild. Lisp, the progenitor of FP created in the 1950s, has not achieved mainstream status. Neither has Haskell, created in 1990, the best-known example of a FP language today.

Clearly, there is an obstacle to the acceptance of FP. I think I know what it is. The functional paradigm is an unnatural way for human beings to think. People normally view the world as comprising objects. Nobody views the world as comprising functions, unless he is trained to do so [1].

(There are some cases, such as mathematical graphs and trees, where the functional paradigm is better suited. But in general, the object paradigm works better for mere mortals.)

As such, schools teach procedural programming as an introductory course. They may later teach functional programming, but untrained minds are best to start with conditionals, loops, mutable state, etc.

I find the introduction of multi-paradigm languages such as Scala and F# to be rather pointless. If you’re not wedded to the functional paradigm 100 per cent, then your software will not benefit much from safety and conciseness. Your program will have side effects; it will have a great deal of mutable state. Most developers will fall back on the procedural crutch because they can.

Perhaps the hope is that, once programmers are given the option of writing FP code, they will see the advantages and gradually switch over. Nice idea, but I seriously doubt this strategy. It’s much more comfortable and convenient to stay with what you know, to adhere to the more natural way to program.

At any rate, the world is pretty much settled on imperative/procedural programming, as well as object-oriented programming (which is a slight twist on the same paradigm). I do not see this changing anytime in this century. However, there may come a time when the operating software of starships is written using FP.

[1] Here’s a great article that illustrates my point: http://goo.gl/kuAYcB

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store