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

后端 未结 10 2049
悲哀的现实
悲哀的现实 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:40

    Jane Street's Brian Hurt wrote a very good article on this a while back. The basic definition he arrived at is that a functional programming language is a language that models the lambda calculus. Think about what languages are widely agreed to be functional and you'll see that this is a very practical definition.

    Lisp was a primitive attempt to model the lambda calculus, so it fits this definition — though since most implementations don't stick very closely to the ideas of lambda calculus, they're generally considered to be mixed-paradigm or at best weakly functional.

    This is also why a lot of people bristle at languages like Python being called functional. Python's general philosophy is unrelated to lambda calculus — it doesn't encourage this way of thinking at all — so it's not a functional language. It's a Turing machine with first-class functions. You can do functional-style programming in Python, yes, but the language does not have its roots in the same math that functional languages do. (Incidentally, Guido van Rossum himself agrees with this description of the language.)

提交回复
热议问题