Why Functional Programming Will Not Take Over The World - A Square Peg In A Round Hole

Functional languages may be fantastic, nevertheless can they map well enough onto what really matters - the brain of the programmer.

Functional programming is really cool. Defining functions and passing them around is a very powerful paradigm. However, hard core functional programming is about expressing a program as a set of functions which define the action of the program. This is effectively a static mathematical definition with known inputs and outputs. The computer will then convert that static definition into a dynamic runtime which actually does the computation needed to get from inputs to outputs.

My concern with functional programming languages is that for humans to understand what they do, we also have to convert their static definition into an internal representation of an imperative, step by step program and actually 'run' that program in our heads.

fun fac 0 = 1
  | fac n = n * fac (n-1)

The above piece of ML is a very simple and clear definition of how to compute a factorial. To understand it one has to say something like:

  1. A number is taken and matched to the two possibilies.
  2. If the number is zero, then 1 is returned.
  3. If the number is non zero, then the eventual return value is multiplied by the number and the function recursed with the number less one.
  4. Eventually, the number passed to recursion will always be zero and so the eventual return is the multiple of original number and all the numbers between it and 0.
1 !r 
2,?n,{ ,?r:Prod !r }:Repeat
The above is VSPL and says, count from 1 to n and multiple r by each number. That is much simpler to understand and the code looks somewhat more similar to how we might think of the computation in our minds.
move 1 to r
perform varying i from 2 by 1 until i>n
    multiply r by i giving r
The above COBOL is quite close to how one might think of a factorial calculation and so needs almost no mental translation.

My conclusion is that simple, sequential, imperative procedural programming languages are forced to continue to dominate coding - because humans think that way.