Live data from Hacker News

Common combinators in JavaScript

gist.github.com

11–20 of 55 posts

Re: Common combinators in JavaScript

#11
post #3

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…

Why do equations use single-letter variables? Or those weird greek symbols? Because they are concise, and their use is so localized that you don't need long names to keep track of them.

Re: Common combinators in JavaScript

#12
post #11
post #3

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…

Why do equations use single-letter variables? Or those weird greek symbols? Because they are concise, and their use is so localized that you don't need long names to keep track of them.

I agree, and I think the use of single letters is appropriate here, but "concise" is not a good enough reason to use short variable names when you're writing code for other people to consume.

In this case, I'd say it's not about being concise, but rather matching the mathematical notation that people are used to seeing when studying these combinators.

Re: Common combinators in JavaScript

#13
post #3

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…

No one would implement this in a real productive project. This is for explanatory reasons only, and aimed at people already familiar with combinatorial logic.

>> I think programming in general, and FP in particular, will become a better place if we all grow up a bit and stop pretending we're too smart to need good naming.

I with you on this, but I think this is a bad example.

And while we are at it, documentation matters as well. The 'good code is the best documentation' attitude[ * ] might be valid if your methods consist of 3 lines and you use 6 methods in 5 modules. But anything bigger will become hard to maintain in the long run.

[ * ]: I encountered this especially in the haskell and erlang world.

Re: Common combinators in JavaScript

#14
post #3

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…

Ehhhh, I hate reading this kind of comment. Can I suggest try to be more humble and read more before having an opinion on something?

Re: Common combinators in JavaScript

#15
post #3

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…

Same reason we use + instead of Math.addTwoIntegers(). Pure snobbery.

Re: Common combinators in JavaScript

#16
post #3

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…

Same reason we use + instead of Math.addTwoIntegers(). Pure snobbery.

However, we don't combine + with other operators to form an illegible mess.

Even ++ is frowned upon for being unreadable/easily missed and/or placed in the wrong spot.

Re: Common combinators in JavaScript

#17
post #3

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…

[deleted]

Re: Common combinators in JavaScript

#19
post #3

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…

They’re just standard “ignore the name this is about how things are combined” notation.

It’s algebra but with functions.

If you read any computer science books they’ll often use this form. It’s a holdover from mathematical notation.

Re: Common combinators in JavaScript

#20
post #3

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…

Ehhhh, I hate reading this kind of comment. Can I suggest try to be more humble and read more before having an opinion on something?

You’re going to get downvotes to hell because of the tone of this (and that’s probably fair) but you raise a good point: that form IS extremely common in basically all technical books. It’s probably more common that O notation.

The comment makes poster look like they haven’t read anything CompSci related.

Post reply on HN