Your first-class functions don’t make you functional

James Fisher
Oct 11, 2014 · 1 min read

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.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

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