News for hackers. Stuff that matters.
Re:Functional Programming Jargon by catnaroek on Monday July 25, 2016 @12:21AM (#12156455)
I'm not so sure. In C++, most certainly a mainstream language, two copies of the complex number `2 + 3i` are equal to each other. In JavaScript, they're different. (Assuming you make two objects with fields `realPart` and `imaginaryPart`.) How can you do functional programming on a foundation where not even the most basic property of equality holds (every value is equal to itself)?

Remember that functions are mappings from values from a domain, into values from a codomain. A language whose treatment of compound values is as feeble as JavaScript's can't possibly constitute the right foundation for doing functional programming.

Re:Functional Programming Jargon by eru on Monday July 25, 2016 @01:11AM (#12156585)
Just define your own equality operator?

Eg in Haskell, whether things can be compared for equality depends on their representation. (Eg church encoded datatypes do not lent themselves to the built-in derivation of the == operator.)

Re:Functional Programming Jargon by wereHamster on Monday July 25, 2016 @01:29AM (#12156661)
If you can't use the builtin `==` operator, you can throw away much of the builtin functionality. The runtime uses `==` in far too many places without ability to provide your own comparator. You want to use your own types as keys in a `Map` or `WeakMap`? Yeah, not going to work.
Re:Functional Programming Jargon by catnaroek on Monday July 25, 2016 @01:21AM (#12156627)
> Just define your own equality operator?

Have fun doing that in JavaScript. Have fun making objects/hashtables use your custom equality operator when comparing field names. Have fun making sure that every single part of your program respects the notion of equality defined by your custom equality operator.

> Eg in Haskell, whether things can be compared for equality depends on their representation.

In any higher-order langauge, that's a feature, not a bug.

Re:Functional Programming Jargon by nomel on Monday July 25, 2016 @12:55AM (#12156541)
Not knowing anything about this, is the end effect the same?
Re:Functional Programming Jargon by catnaroek on Monday July 25, 2016 @01:22AM (#12156633)
The effect is that, if you want to reason about JavaScript programs, you can't carry out your reasoning in JavaScript itself, but rather have to use an external metalanguage - ideally something like Hoare logic, but, realistically, usually an informal, insufficiently understood, even insufficiently defined language, like English.

OTOH, a Haskeller can reason about Haskell programs by just evaluating Haskell expressions.