4 ms·
Why do functional programming examples always use such short names? I feel like it adds extra cognitive overhead to trying to learn something that's got plenty
by mrcrumb1 4y ago
Why do functional programming examples always use such short names? I feel like it adds extra cognitive overhead to trying to learn something that's got plenty of foreign concepts to grok.
- giraffe_lady 4y agoI suspect the ideal behind that is the "variables with small scope should have shorter names" concept. So in a one-liner it's ok to abbreviate. I don't necessarily agree with this especially for examples. But in practice I haven't found the fp communities I'm familiar with (clojure and ocaml) to be too bad about using confusingly terse names. Php and go are by far the worst there, again at least from my experience.
- brucie 4y agoIsn’t it a kind of proof that a function is generic? I can map over some xs with an f and produce ys.
- zem 4y agoa lot of the time there are patterns and idioms that occur very frequently in the language, and have evolved a set of standard short names, e.g. "xs" for a list and then "x" for the element in an iteration, or "acc" for an accumulator parameter in a recursive function.
- zumu 4y agoOften the expressiveness of the type system captures info you'd have to stuff in the name in something like Java or python or at least they just want to emphasize the types over the names. Not always the case though.