4 ms·
Wikipedia is far from the be-all and end-all source, but at least it is one, so here’s a quote from https://en.wikipedia.org/wiki/Functional_programming https:/
by minitech 10y ago
Wikipedia is far from the be-all and end-all source, but at least it is one, so here’s a quote from https://en.wikipedia.org/wiki/Functional_programming https://en.wikipedia.org/wiki/Functional_programming: “It is a declarative programming paradigm, which means programming is done with expressions[1] or declarations[2] instead of statements.” I would agree with it that the usual meanings of “procedural language” and “functional language” are not compatible.
- catnaroek 10y agoAny procedural language, not only functional ones, can be expression-oriented, rather than statement-oriented, e.g., Ruby. And Prolog programs are literally lists of declarations (of inference rules), yet Prolog isn't a functional language.
- minitech 10y agoThe quote says functional programming is a type of declarative programming, not the other way around. Prolog is irrelevant. Backing up to equality as an aside, is there any language that will let you determine whether two functions are equal? If the functions that can be compared aren’t restricted to some silly level and the language is Turing-complete, I can’t imagine any better behaviour than Haskell’s that you already mentioned, which you can bring to JavaScript pretty easily.
- catnaroek 10y ago> The quote says functional programming is a type of declarative programming, not the other way around. Well, your quote doesn't even provide a full definition, sooo... > Backing up to equality as an aside, is there any language that will let you determine whether two functions are equal? No, that's obviously undecidable. (Rice's theorem.) But read what I said more carefully. Did I ever say “A functional language lets you determine whether two functions are equal?” I didn't! What I said is “A functional language doesn't let you distinguish equal functions.” Not letting you test functions for equality is a perfectly valid (and, in fact, the only valid) approach in a higher-order language. > which you can bring to JavaScript pretty easily. Not really. I can't undefined JavaScript's existing equality operator.
- minitech 10y ago> a perfectly valid (and, in fact, the only valid) approach I thought as much and it would really help if you would just say these sorts of things outright so the comments are actually useful instead of deeply nested wording quibbles. With that out of the way: you can define a subset of JavaScript that satisfies your third condition by saying “don’t compare functions”. That’s why I didn’t consider it a meaningful condition. Functional programming works best as a paradigm and then we can just call languages where it’s standard “functional languages”. Much simpler.
- catnaroek 10y ago> I thought as much and it would really help if you would just say these sorts of things outright so the comments are actually useful instead of deeply nested wording quibbles. I find it absolutely essential to make perfectly clear what exactly I'm refuting. > With that out of the way: you can define a subset of JavaScript that satisfies your third Second. > condition by saying “don’t compare functions”. That's a different language. Do you know of any implementation of it? > Functional programming works best as a paradigm and then we can just call languages where it’s standard “functional languages”. Much simpler. Nope. A functional language is one that makes it easy to write functional programs, by satisfying the conditions I gave above. A programming language is first and foremost its semantics, whatever the culture of its users.
- minitech 10y ago> Nope. A functional language is one that makes it easy to write functional programs, by satisfying the conditions I gave above. Except you’ve still given no source for the conditions, condition -1 (“a functional language is a procedural language”) is wrong, and a language satisfying the conditions in no way makes it easier to write a functional program just by virtue of satisfying the conditions (because they can be satisfied entirely by removing features you don’t have to use). Maybe you meant “harder to write non-functional programs”. > Second. The last item in a list of three items is not the second item.