Live data from Hacker News

Why Operators Are Useful

neopythonic.blogspot.com

21–30 of 173 posts

Re: Why Operators Are Useful

#21

he doesn’t make any coherent argument as to why one is more clear or preferred than the other. he simply states it and moves on with this bias. for example, when he compares 2 to 2a, i feel he doesn’t really address anything and just states his preference as the more clear one. plus, he of course seems to know nothing about lisp (or just ignores it) where you might have: (+ a (+ b c)) = (+ (+ a b) c) = (+ a b c) all…

Isn't "...once you've learned this simple notation, equations written using them are easier to manipulate than equations written using functional notation..." his argument why operators are more clear? I don't necessarily agree with that, but I haven't made a world class programming language, either. I just assume he knows something I don't.

but programming isn’t about manipulating equations. if you want programs to manipulate equations, then again, the procedure notation, in particular lisp notation, wins out.

Re: Why Operators Are Useful

#22
post #9

Earlier quoted context omitted.

Sorry, is it xz + yz = x(y + z) when using operators? That seems wrong.

I don't know any Lisp, but I would decode (= (* x (+ y z)) (+ (* x z) (* y z))) As x*(y + z) = x*z + y*z e.g. (+ y z) means you add y and z with highest priority.

Which is incorrect, they aren't equal.

Re: Why Operators Are Useful

#23
post #2

This is much less confusing than (2), and leads to the observation that the parentheses are redundant, so now we can write "x + y + z" This is a non-problem if you're using Lisp. (+ x y z) accepts an arbitary number of arguments and the operator precedence problem does not exist since there is no operator precedence.

This is a non-problem in every language with variadic functions. "add(x, y, z)" looks good to me.

Re: Why Operators Are Useful

#24
post #7

Earlier quoted context omitted.

Some would argue that the fact that you have all of those alternative forms is part of the problem. Lisp is one of the (if not the) most individualistic programming languages around. Lisp makes it easy for a programmer to create their very own impenetrable, arcane, domain specific languages. This causes large organizations to avoid it like the plague. Large teams don't want artists, they want replaceable parts.

Some would argue that Lego and Technic are too complicated, and we should all play with Duplo. Thankfully, Michelangelo and Leonardo were not in large teams. Which do you aspire to be: a cog or an artist?

I think most people would prefer to be an artist, but art rarely pays the bills, hence the cliche "starving artist." My post was not meant to rip on artists, though that's how it comes off now that I read it again. The truth is that society wants more cogs but needs more artists.

Re: Why Operators Are Useful

#25

he doesn’t make any coherent argument as to why one is more clear or preferred than the other. he simply states it and moves on with this bias. for example, when he compares 2 to 2a, i feel he doesn’t really address anything and just states his preference as the more clear one. plus, he of course seems to know nothing about lisp (or just ignores it) where you might have: (+ a (+ b c)) = (+ (+ a b) c) = (+ a b c) all…

> doesn’t really address anything and just states his preference as the more clear one

Maybe he doesn't understand why one is less confusing to him than the other one. Doesn't mean it's not like that for most people though. The reason it's less confusing is familiarity and simplicity (it's simpler form and it's already familiar).

Re: Why Operators Are Useful

#26
A “dict” operator would be vague because there is more than one way to combine dictionaries. Why should I have to guess whether duplicate keys are being skipped or replaced by a symbol, when two different well-named functions will always make it clear?

Re: Why Operators Are Useful

#27

Earlier quoted context omitted.

I don't know any Lisp, but I would decode (= (* x (+ y z)) (+ (* x z) (* y z))) As x*(y + z) = x*z + y*z e.g. (+ y z) means you add y and z with highest priority.

Which is incorrect, they aren't equal.

Well, technically it solves to x = z when y 0 and any x, z when y = 0 though I'm not sure if that's the original intention.

Re: Why Operators Are Useful

#28

A “dict” operator would be vague because there is more than one way to combine dictionaries. Why should I have to guess whether duplicate keys are being skipped or replaced by a symbol, when two different well-named functions will always make it clear?

Same with lists and strings, and it doesn't bother anybody: even for dict, it's just a matter or reading from the left to the right.

Re: Why Operators Are Useful

#29
post #2

This is much less confusing than (2), and leads to the observation that the parentheses are redundant, so now we can write "x + y + z" This is a non-problem if you're using Lisp. (+ x y z) accepts an arbitary number of arguments and the operator precedence problem does not exist since there is no operator precedence.

If this is so obviously preferable, why have mathematicians so obdurately not adopted this style? Mathematical notation is not an archaic practice that is followed out of a respect for tradition, or a doctrine that has been developed from first principles, it is something that has evolved (and continues to do so) because it has been useful.

Well mathematics notation largely follows speech. People say “one plus two” — largely because speech doesn’t have closing parentheses, so we need to speak in a way that makes it clear when we’re done talking — so that’s how we write it. But for a computer, prefix notation is great because it’s unambiguous and clear even without knowledge of PEMDAS. Similar to how Americans write MM/DD/YYYY because that’s how we say dates, but we can still acknowledge that YYYY-MM-DD is the best format for computers.

Re: Why Operators Are Useful

#30

A “dict” operator would be vague because there is more than one way to combine dictionaries. Why should I have to guess whether duplicate keys are being skipped or replaced by a symbol, when two different well-named functions will always make it clear?

Same with lists and strings, and it doesn't bother anybody: even for dict, it's just a matter or reading from the left to the right.

Of course it’s not the same. There is one sensible result expected when adding two lists or strings together (since they’re linear, it would not make sense to encourage inefficient search/replace operations with an operator; and also, the containers do not require unique keys, you can simply extend them). A dict must deal with conflicting keys, and arguably each situation requires different treatment of those keys.
Post reply on HN