Hacker News new | past | comments | ask | show | jobs | submit
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.

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.

I don't think your experience is particularly universal, it vastly differs depending on what kind of programming you do. If you're doing games stuff or graphics or signal processing or any other number of subfields of programming that require a lot of math, operators are a god-send for readability.

This Zig change is the best of both worlds: avoid the ambiguity, but keep the readability.

There are plenty of languages, like e.g. Ruby, where operators are just sugar for functions or methods. Meaning they can still be partially applied, have their value taken, and/or passed as callbacks.

If your language doesn't allow you to do the same thing with operators as you can do with functions, that's a language design issue and has nothing to do with operators as a concept.

> 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.

It depends on what things you work on. When I'm writing 'math-y' code (GPU shaders for renderng etc) then I want the expressions to look close to the reference paper and not artificially split them up into multiple lines of code with function calls instead of operators.

I don't think character length of an expression is the issue. Reading chained operators is explicitly easier than reading nested functions by virtue of operators having infix notation and not explicitly requiring parantheses where they are not necessary to disambiguate order of operations. The prefix notation of functions moves the operation farther from the eye from operands and introduces the issue of parantheses-miscounting bugs. I'd hardly say the difference in readability of these is a non issue:

(a + b + c + d) * e

mult(add(a, add(b, add(c, d))), e)

loading story #50377589
loading story #50377478
loading story #50377464
Operators can also support those things. Operators are just syntax sugar for functions, or at least they're capable of being such. If a language chooses not to support the full range of what functions can do for operators, that is a thing you can criticise the language for (and I do!), but it is not a reason to suggest operators should be disposed with in language design altogether.