“Functional programming” has a clear meaning, but does “functional language”?

后端 未结 10 2048
悲哀的现实
悲哀的现实 2021-02-01 16:12

I understand very clearly the difference between functional and imperative programming techniques. But there\'s a widespread tendency to talk of \"functional languages\

10条回答
  •  失恋的感觉
    2021-02-01 16:39

    I like @Randolpho's answer. With regards to features, I might cite the list here:

    Defining point of functional programming

    namely

    • Purity (a.k.a. immutability, eschewing side-effects, referential transparency)
    • Higher-order functions (e.g. pass a function as a parameter, return it as a result, define anonymous function on the fly as a lambda expression)
    • Laziness (a.k.a. non-strict evaluation, most useful/usable when coupled with purity)
    • Algebraic data types and pattern matching
    • Closures
    • Currying / partial application
    • Parametric polymorphism (a.k.a. generics)
    • Recursion (more prominent as a result of purity)
    • Programming with expressions rather than statements (again, from purity)

    The more a particular programming language has syntax and constructs tailored to making the various FP features listed above easy/painless to express & implement, the more likely someone will label it a "functional language".

提交回复
热议问题