Your first-class functions don’t make you functional

James Fisher
1 min readOct 11, 2014

--

I’m sure you’ve heard the following claim before: “finally, language L has first-class functions; now we can do functional programming!” But first-class functions are simply not relevant, and here’s why.

A language L is “functional” to the extent that a “function” defined in L is actually a mathematical function. The property that makes L a functional language is not the existence of first-class functions, but the existence of mathematical functions.

These two properties, being first-class and being mathematical, are orthogonal. This means we can draw up four classes of languages by whether their functions are first-class and whether they are mathematical.

Languages like C have neither first-class functions nor mathematical functions. At the other end of the scale, languages like Agda have functions which are both first-class and truly mathematical. In between, Java 8+ and many other languages have functions which are first-class but not mathematical. In the final class, the C preprocessor could be seen as a language with mathematical functions (macros) but without first-class functions.

So, sorry Java 8, but your closures can’t help. You’ll never even be as “functional” as the C preprocessor.

--

--