Search code examples
functional-programmingprogramming-languages

When a language qualifies as a functional language?


What are the traits a language should have to be qualified as a functional language? When we can say that a language XYZ supports functional paradigm?


Solution

  • What are the traits a language should have to be qualified as a functional language? When we can say that a language XYZ supports functional paradigm?

    Those are two different question. I'd say that "supporting functional paradigm" means:

    • you can work with functions like with other types (use them in local variables, parameters, …)
    • you can define anonymous functions (a.k.a. lambda functions) inline
    • anonymous functions can access variables declared in their environment (this is known as closure)

    By this definition, pretty much any modern mainstream programming language supports the functional paradigm (with the exception of C).

    To be classified as "functional language", a language needs to focus on the functional paradigm as its primary or only paradigm, including immutability and focus on pure (side-effect-free) functions. Apart from the above, this usually means:

    • support for declaring immutable types like discriminated unions
    • support for pattern matching
    • function bodies are composed of expressions, not statements