Functional Programming – Are Closures Sufficient to Characterize It?

closuresfunctional programming

All functional programming languages that I know of (e.g. Haskell, Scala, Scheme, Clojure, SML, OCaml, …) support a notion of closures.

Also, I often read that a language X can be considered functional because it supports closures.

On the other hand there are programming languages that do have closures but are not considered functional. The best example I know of is Smalltalk: Smalltalk has blocks (which in most implementations behave like closures, see e.g. here) but it is considered a pure object-oriented language.

So, while closures are a very common (or even essential) construct in functional programming, are they really sufficient to characterize functional programming? If the support of closures is sufficient for considering a language functional, why isn't Smalltalk considered functional too?

Or is the notion of a closure orthogonal to both functional and
object-oriented programming?

Best Answer

The hallmarks of functional programming languages:

  • Higher Order Functions. (Passing functions as parameters, storing functions in data structures, returning functions, creating functions at runtime).
  • Encouraging "Referential transparency".
  • And I would dare to say "Laziness".
  • Immutability

A functional programming language makes a heavy use of Functional Data Structures.

Having Closures doesn't mean the language is "Functional". Examples: Java 8 (if Lambdas are going to be added), Groovy and Objective-C,

Edit:
Based on the comment, I removed Memoization from the previous list.

Functional programming languages employs the "Memoization" technique because it is easier with Functional code.