logoalt Hacker News

anonymous908213 • today at 9:58 AM • 1 reply • view on HN

Because it's ridiculously verbose. Abbreviating extremely common operations makes code far easier to read and understand than not.

> have to understand precedence

Precedence is not in any way an argument against using operators; you could disallow precedence at all (eg. each expression must have at most one operator, or rather two counting the assignment operator) while still having operators. That said, precedence is also very beneficial to readability when not abused.

> Operators cause issues because it is not possible to cleanly express error output from an operator

Incorrect. An operator can simply desugar to functions, and therefore has the exact same error semantic possibilities. If you take issue with a language not returning errors from operators, that is a language design issue, not something inherent to the existence of operators.


Replies

epolanski • today at 10:06 AM

The amount of times I've been sad that multiply or sum are longer than + or * is limited to long formulas and even then it's a non issue.

Also, functions can be used as callbacks, and offer overloads to handle partial applications with ease, pipe(2, sum(3), multiply(2)), e.g.

➕ show 5 replies