This site embodies everything I dislike about functional programming: an attitude that shorter and less specific is better. What use is a line like const S = f => g => x => f(x)(g(x)); for anyone except someone who already groks what the S combinator does and is for? Why do these combinators have single-letter names anyway? Does that help anyone? Even Haskell, heaven on earth for single-letter guess-what-i-mean coder…
Common combinators in JavaScript
41–50 of 55 posts
Re: Common combinators in JavaScript
#42Earlier quoted context omitted.
const S = f => g => x => f(x)(g(x)); I'm more likely to write const geed = g(x); const effed = f(x); const S = effed(geed); I have no idea when I would actually write a structure like this though. Can someone please fill those names in with something like `buildComparator` or `Math.max.apply` or something, anything, that remotely makes sense?
It's one of those things that you arrive at yourself. You rarely, if ever, understand them from Haskell-ish mathematical-ish constructs like these. Sometimes you could end up with this code in situations like this: const data = getDataForUser(user); const transformer = getTransformersForGDPR(); const sanitizedData = transformer(data); where getTransformersForGDPR returns a single function that may contain a chain of…
const data = getDataFromState(state);
const transformer = getTransformersForState(state);
const sanitizedData = transformer(data);Re: Common combinators in JavaScript
#43This site embodies everything I dislike about functional programming: an attitude that shorter and less specific is better. What use is a line like const S = f => g => x => f(x)(g(x)); for anyone except someone who already groks what the S combinator does and is for? Why do these combinators have single-letter names anyway? Does that help anyone? Even Haskell, heaven on earth for single-letter guess-what-i-mean coder…
This is why I don't like math. I guess mathematicians write like that because it's faster to write on a blackboard. When I do it myself in code I always go back and rename those single letter variables to proper names. It forces me to know what the code actually resembles, not just a formula I learned by heart.
Most math texts have a fair amount of documentation when formulas are introduced. Perhaps substantially more than the table in this article.
Re: Common combinators in JavaScript
#44Earlier quoted context omitted.
This is why I don't like math. I guess mathematicians write like that because it's faster to write on a blackboard. When I do it myself in code I always go back and rename those single letter variables to proper names. It forces me to know what the code actually resembles, not just a formula I learned by heart.
I’m not going to defend single letter names (although shortness does have some virtue compared to some monstrous naming conventions), but... Most math texts have a fair amount of documentation when formulas are introduced. Perhaps substantially more than the table in this article.
Re: Common combinators in JavaScript
#45Is there a reason why functional programming algebra insists on using one letter identifiers?
It's intentionally to get across the idea that you don't, and shouldn't, know anything about these arguments within this scope beyond "this is a function" and "this is an argument". These functions just define how to combine things; if you knew any more about the arguments, it would be breaking the abstraction. The only better names you could really give are ones like func1, func2, arg1, arg2, which don't add any inf…
Re: Common combinators in JavaScript
#46Is there a reason why functional programming algebra insists on using one letter identifiers?
Mathematicians insist on one-grapheme identifiers, partly due to tradition and aesthetics, and partly because at some point juxtaposition came to represent multiplication, so what xy means would be ambiguous.
Of course, a true programmer delegates even the simplest calculation to a computer, so they have less of a need for notation that is easy to manipulate.
Re: Common combinators in JavaScript
#47This site embodies everything I dislike about functional programming: an attitude that shorter and less specific is better. What use is a line like const S = f => g => x => f(x)(g(x)); for anyone except someone who already groks what the S combinator does and is for? Why do these combinators have single-letter names anyway? Does that help anyone? Even Haskell, heaven on earth for single-letter guess-what-i-mean coder…
Re: Common combinators in JavaScript
#48This site embodies everything I dislike about functional programming: an attitude that shorter and less specific is better. What use is a line like const S = f => g => x => f(x)(g(x)); for anyone except someone who already groks what the S combinator does and is for? Why do these combinators have single-letter names anyway? Does that help anyone? Even Haskell, heaven on earth for single-letter guess-what-i-mean coder…
Re: Common combinators in JavaScript
#49This site embodies everything I dislike about functional programming: an attitude that shorter and less specific is better. What use is a line like const S = f => g => x => f(x)(g(x)); for anyone except someone who already groks what the S combinator does and is for? Why do these combinators have single-letter names anyway? Does that help anyone? Even Haskell, heaven on earth for single-letter guess-what-i-mean coder…
Your critique is like someone claiming imperative coders are horrible and don't value naming because of assembly language.
Re: Common combinators in JavaScript
#50Is there a reason why functional programming algebra insists on using one letter identifiers?
In reality, expanding a lambda expression into SKI combinators takes up a lot of space. Since the notation is mainly for language implementors, using the short mnemonics allows you to compress the size of the resultant expression.
It's the same reason why the x86 opcode is named 'mov' not 'move'.