5 ms·
> the majority prefer a language that is closer to the human Closer to "the human"? Do you know more than 3 people who know C++ operator precedence? Humans d
by anamax 15y ago
> the majority prefer a language that is closer to the human
Closer to "the human"? Do you know more than 3 people who know C++ operator precedence?
Humans don't handle operator precedence very well.
- haberman 15y agoWhy then has math (which is read and written only by humans) used infix notation for hundreds of years, whereas prefix/postfix notation were only developed in the 20th century and today are used only by Computer Scientists? You don't have to know an entire operator precedence table to read and write idiomatic infix-notation code. Precedence is defined such that common expressions evaluate as people intuitively expect (a notable counterexample is "x & y == z" in C). Parentheses are always available to clarify more complicated expressions.
- brlewis 15y agoHumans who do a lot of math switch notations when convenient. For example, for addition we'll sometimes put a summation sign in prefix notation. For division we like to put the numerator above the denominator, a notation that's inconvenient in a programming language. Come to think of it, humans usually add and subtract by stacking numbers vertically. I don't think you can point at infix notation as "the" human-friendly notation.
- Volpe 15y agoHave you seriously seen (non-computer) people write simple arithmetic as + 1 3 ? This feels like a discussion based in fiction...
- lispm 15y agoI've seen lots of people doing 1 enter 2 + on their HP calculators. Using them with RPL, reverse polish lisp.
- burgerbrain 15y agoPostfix notation is popular in the financial industries.
- burgerbrain 15y agoOne could have made the same argument in favour of Roman numerals, in the face of the less familiar Arabic numerals
- jhuni 15y agoMath was written on paper long before there were computers. As a result, the use of infix notation was an act of necessity not a calculated decision. Now that we have computers and keyboards we should use prefix notation.
- lispm 15y agoif you look at math on paper, that's definitely not 'infix'.
- CJefferson 15y agoSo you think we should teach in schools (from an example above): (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)) ?
- burgerbrain 15y agoSeems like a great idea to me. I take it you think there is something intrinsically wrong with that idea?
- CJefferson 15y agoCertainly, I would hope it would have been obvious, but we might each have different opinions of obvious! I find it very hard, without bracket counting, to see exactly what the '+' and '/' bind to. With the more traditional: (-b + sqrt(bb-4ac)) / (2a) I find in only a glance I can tell what everything is binding to.
- anamax 15y ago> I find in only a glance I can tell what everything is binding to. It must be nice to live in a world with only 4 infix operators and expressions that have only 3 infix operators. For example, lots of folks think that sqrt should be a prefix operator, not yet another function. I suppose you're going to assume that the top bar will serve as parentheses. BTW "-b + sqrt(bb-4ac) / 2a" is the interesting expression. Is it "(-b + sqrt(bb-4ac)) / (2a)" or "-b + (sqrt(bb-4ac)) / 2a)" And, are you certain what "bb-4ac" means? (There's at least one major language where it doesn't mean "(bb)-(4ac)".)
- 6ren 15y agoIt's even stronger, in that mathematics generalized arithmetic algebra into groups, fields, rings and other things I don't understand. Examples of specific algebras include: boolean, relational and Kleene (aka regular expressions). Other notations are used, but with a frequency similar to pre-fix (lisp) and post-fix (forth). "Associativity" (not affected by order of evaluation) only makes sense for in-fix. But it really could just be familiarity, I guess. I can't see how to determine it either way. But regardless of the cause, there's overwhelming evidence that people, in fact, prefer in-fix.
- anamax 15y ago> But regardless of the cause, there's overwhelming evidence that people, in fact, prefer in-fix. How many people have seen anything other than in-fix? Of those, how many got a fair shot at an alternative?
- anamax 15y ago> You don't have to know an entire operator precedence table to read and write idiomatic infix-notation code. If it's "idiomatic", why is there such disagreement? > Why then has math (which is read and written only by humans) Convention has a lot of value. That said, mathematicians don't have to worry about getting things wrong. It's just paper, and they're happy to let humans fix up the errors. > Parentheses are always available to clarify more complicated expressions. Unnecessary parentheses are how humans deal with the fact that they can't handle infix.