News for hackers. Stuff that matters.
Re:Admitting That Functional Programming Can Be Awkward (2007) by kibwen on Saturday October 24, 2020 @01:46PM (#24880749)
> Functional programming as a concept is well defined, and it's not merely "first-order functions".

Then, sincerely, what is the definition? Does that definition succeed in excluding languages that are not considered functional, e.g. C++, Java, Python, Go? And if it doesn't, and the definition is so broad as to encompass every language, then what is the useful purpose of going out of one's way to label a language as "functional"?

Re:Admitting That Functional Programming Can Be Awkward (2007) by pyrale on Saturday October 24, 2020 @02:49PM (#24881142)
This quote elsewhere in the thread lines up with my knowledge:

> Functional programming was never about first-class functions. It was always about programming with pure and total functions in their mathematical version.

Other people have correctly pointed out that this is an extremely ambitious idea, since, as they have noted, you can't build a turing-complete language with pure and total functions.

This very high bar explains why there has been so many different design decisions in languages, and why most fp languages make tradeoffs in order to reach a compromise between what they believe is important in that concept, and what they can pull in terms of usable software.

As I noted as a response to that thread, we have seen in the recent years languages that achieve pure/total functions, but this was only possible because so many forebearers had tried different designs, and comprmised to produce usable software they could iterate from.

Re:Admitting That Functional Programming Can Be Awkward (2007) by benrbray on Saturday October 24, 2020 @02:06PM (#24880862)
Functional programming languages, more often than not, distinguish themselves with some combination of the following features:

* First-order functions

* Partial function application / currying

* Type inference

* Algebraic data types

* Typeclasses

* An emphasis on pure functions (side effects must be explicitly annotated), opening up more possibilities for static analysis

* Lazy evaluation

This is not to say that the above features cannot be emulated by other languages. For instance, Rust has traits, which serve more or less the same practical purpose as Haskell typeclasses.

However, FP is designed to prioritize the above features, whereas other languages may not be.

Re:Admitting That Functional Programming Can Be Awkward (2007) by lifthrasiir on Saturday October 24, 2020 @02:22PM (#24880966)
> However, FP is designed to prioritize the above features, whereas other languages may not be.

This statement is pretty vauge and further supports kibwen's claim that a term "functional programming" ceased to be meaningful or is in the course of being so. I can't see the reason that Rust is not as functional as OCaml by your standard, as both fill four boxes out of seven (only OCaml has currying, only Rust has typeclasses). It can be argued that Rust was not originally designed as functional one, but that would be absurd because it doesn't relate to the current language.