4 ms·
Saying this about JavaScript of all languages... The pipe operator is about the least likely to be confusing to a beginner. And it's hardly "esoteric" when it'
by throwamon 5y ago
Saying this about JavaScript of all languages... The pipe operator is about the least likely to be confusing to a beginner.
And it's hardly "esoteric" when it's been around for decades in well-established languages (including bash, for God's sake). Just like the other commenter, you're only showing your ignorance of other paradigms here. Just because you were introduced to something else first, doesn't mean it's automatically the most intuitive way for everyone forever.
- magicalist 5y ago> including bash bash scripts famous for being readable and maintainable :P
- throwamon 5y agoI fully agree with your sarcasm, but you probably know that that was not my point. But seriously, I don't see what's so controversial about it. It's just "do this, then take the result and do that, then take the result and..." Everyone understands this intuitively. Plus, lots of libraries already do method chaining, which is just a crappier and inconsistent version of piping anyway.
- irrational 5y agoI disagree. A true begineer is unlikely to be familiar with bash or these other languages. Syntax like + - / * () = etc. are not esoteric since, for the most part, they work similar to math they learned in school. But => and |? They are esoteric. As a beginner you have no idea what they will do without study.
- throwamon 5y ago> for the most part That's the important bit. If they always worked as expected, I'd agree. But they don't. I could give plenty of examples but I'm sure you know about them. > A true begineer is unlikely to be familiar with bash or these other languages I'm with you on Bash, but not necessarily about "these other languages". Lots of people are being introduced to functional languages first, and if you don't think so you're probably just old. I also don't assume a beginner will just be given code without any guidance. What do you think about dot notation? If they can/can't understand `foo().bar().baz()`, then surely they can/can't understand `foo() |> bar() |> baz()` all the same? Actually the "lack of familiarity" argument is the best argument for introducing it in JavaScript: It's the language beginners are learning nowadays, so if it has feature x as a prominent feature, in a few years everyone will know about it.
- smaccona 5y ago> … and if you don't think so you're probably just old. I resemble that remark! (apologies to all; too good to pass up)
- mcaruso 5y ago=> also comes straight from math learned in school. There it's written → (for function signatures), and (the more rare) ↦ for function definitions.