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

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

    You can do functional style programming in any language. I try as much as possible.

    Python, Linq all promote functional style programming.

    A pure functional language like Haskell requires you to do all your computations using mathematical functions, functions that do not modify anything, they just return values.

    In addition, functional languages typically allow you to write higher order functions, functions that take functions as arguments and/or return types.

    0 讨论(0)
  • 2021-02-01 16:21

    A language (and platform) that promotes Functional Programming as a means of fully leveraging the capabilities of the said platform.

    0 讨论(0)
  • 2021-02-01 16:21

    I think the same question can be asked about "OOP languages". After all, you can write object oriented programs in C (and it's not uncommon to do so). But C doesn't have any built-in language constructs to enable OOP. You have to do OOP "by hand" without much help from the compiler. That's why it's usually not considered an OOP language. I think this distinction can be applied to "functional languages", too: For example, it's not uncommon to write functional code in C++ (think about STL functions like std::count_if or std::transform). But C++ (for now) lacks built-in language features that enable functional programming, like lambdas. (Let's ignore boost::lambda for the sake of the argument.)

    So, to answer your question, I'd say although it's possible to write function programs in each of these languages:

    • C is not a functional language (no built-in functional language constructs)
    • Scheme, Python and friends have functional constructs, so they're functional languages. But they also have imperative and OOP constructs, so they're usually referred to as "multi-paradigm" languages.
    0 讨论(0)
  • 2021-02-01 16:21

    Haskell for one have different types for functions with side-effects and those without.

    That's a pretty good discriminating property for being a 100% functional language, at least IMHO.

    0 讨论(0)
  • 2021-02-01 16:32

    I would say that a functional language is any language that allows functional programming without undue pain.

    0 讨论(0)
  • 2021-02-01 16:33

    I wrote a (pretty long) analysis once on why the term 'functional programming language' is meaningless which also tries to explain why for instance 'functions' in Haskell are completely different from 'functions' in Lisp or Python: http://blog.nihilarchitect.net/archives/289/on-functional-programming/

    Things like 'map' or 'filter' are for a large part also implementable in C for instance.

    0 讨论(0)
提交回复
热议问题