Live data from Hacker News

If-then-else had to be invented

github.com

61–70 of 255 posts

Re: If-then-else had to be invented

#61
post #5

Ah, interesting, I wish the title had been prefixed with "What if ". There's a language where THEN basically means ENDIF... Forth, if memory serves me right?

Yes, and the inventor of the language eventually removed ELSE from his dialects, amusingly. These days he says that his code has very few conditional statements. I think the tactic strategy to achieve this is to confine conditional branches in a few well chosen words. For instance if you have a word SORT that sorts the top pair on the stack, which has to have a branch: : SORT 2DUP then you can build "if-less" MIN, MA…

Despite my somewhat crippled ability to think RPN, I love the simplicity and expressiveness of the above.

Re: If-then-else had to be invented

#62
Interesting timing. I just read https://arstechnica.com/?post_type=post&p=1728174 due to r/programming https://www.reddit.com/r/programming/comments/kbs11a/a_damn_... yesterday.

Apparently Cambridge Programming Language (more or less a failed language that became proto-C) designer Christopher Strachey had some misgivings about this usage of "else".

Re: If-then-else had to be invented

#63

I remember there was a paper that tried to compare natural language usage of common programming language keywords to see if they may come up with other constructs to create a programming language that is easier to learn as your first one. There were a few interesting observations. The one that stuck with me the most is that 'and' is most commonly used with almost the opposite sense in natural language vs programming:…

The word “and” in English is simply there to join multiple clauses together. Whether it is a set union or set intersection, (or some other relations) depends on the sentence. Set union: they can read and write’ Set intersection: my jeans were creased and dirty Sequential: he turned round and walked out Causal: there was a flash flood and by the next morning the town was under water’ And, there are many more usages.

It's surprising how often you can replace 'but' with 'and' in a sentence.

Re: If-then-else had to be invented

#64

I remember there was a paper that tried to compare natural language usage of common programming language keywords to see if they may come up with other constructs to create a programming language that is easier to learn as your first one. There were a few interesting observations. The one that stuck with me the most is that 'and' is most commonly used with almost the opposite sense in natural language vs programming:…

Great observations. In the same idea, "or" is inclusive in all of programming and CS, i.e. A and B => A or B, but in natural languages (as least the ones I know) "or" is almost always exclusive, i.e "do you want to eat pizza or pasta?" does not imply that eating both is an option. This is of course related to why the famous joke "Is it a boy or a girl? Yes." is so hilarious.

Latin has both in inclusive ('vel') and exclusive ('aut') or.

Re: If-then-else had to be invented

#65
post #33

I guess the unknown German word mentioned in the post is probably "sonst". It can be translated to "otherwise" or "else". And "wenn...dann...sonst" sounds perfectly natural in German.

Willing to bet it's either "sonst" or "andernfalls"... I'd suspect the latter, the former is a little bit too informal for mathematicians. Both of these are commonly used for case enumerations in math.

As a research mathematician, I happily use "sonst" in e.g. case distinctions (well, in my undergrad lecture notes; papers are written in English ) and wouldn't use "andernfalls" as it is simply too long :-). Moreover, if they had looked up "andernfalls" in a dictionary, they would have found "otherwise" as translation. For "sonst", the number 1 translation in all dictionaries I have around or found online, is "else".

So I firmly believe they used "sonst".

Re: If-then-else had to be invented

#66

I remember there was a paper that tried to compare natural language usage of common programming language keywords to see if they may come up with other constructs to create a programming language that is easier to learn as your first one. There were a few interesting observations. The one that stuck with me the most is that 'and' is most commonly used with almost the opposite sense in natural language vs programming:…

"we usually describe operations on sets as taking the whole set as an argument, not in terms of what happens with each individual member"

Doesn't R do it like that too?

Re: If-then-else had to be invented

#67

I remember there was a paper that tried to compare natural language usage of common programming language keywords to see if they may come up with other constructs to create a programming language that is easier to learn as your first one. There were a few interesting observations. The one that stuck with me the most is that 'and' is most commonly used with almost the opposite sense in natural language vs programming:…

Great observations. In the same idea, "or" is inclusive in all of programming and CS, i.e. A and B => A or B, but in natural languages (as least the ones I know) "or" is almost always exclusive, i.e "do you want to eat pizza or pasta?" does not imply that eating both is an option. This is of course related to why the famous joke "Is it a boy or a girl? Yes." is so hilarious.

> "or" is almost always exclusive, i.e "do you want to eat pizza or pasta?" does not imply that eating both is an option.

English is way too ambiguous for this example and often relies heavily on context. Wanting to eat pizza does not preclude also wanting to eat pasta. If it was exclusive or, and you wanted to eat both pizza and pasta, the honest answer to this question would be "no," but what you should say is "yes."

Re: If-then-else had to be invented

#68
post #58

Earlier quoted context omitted.

The word “and” in English is simply there to join multiple clauses together. Whether it is a set union or set intersection, (or some other relations) depends on the sentence. Set union: they can read and write’ Set intersection: my jeans were creased and dirty Sequential: he turned round and walked out Causal: there was a flash flood and by the next morning the town was under water’ And, there are many more usages.

How is your set union example not another intersection (your quantification could go in one of two places though, they = (set of readers) cap (set of writers) versus they = { p in people such that (p writes) cap (p reads) }.

It depends if you consider the implied set to be the people (of which there are readers and writers) or the capabilities (reading and writing).

Re: If-then-else had to be invented

#69

I remember there was a paper that tried to compare natural language usage of common programming language keywords to see if they may come up with other constructs to create a programming language that is easier to learn as your first one. There were a few interesting observations. The one that stuck with me the most is that 'and' is most commonly used with almost the opposite sense in natural language vs programming:…

Great observations. In the same idea, "or" is inclusive in all of programming and CS, i.e. A and B => A or B, but in natural languages (as least the ones I know) "or" is almost always exclusive, i.e "do you want to eat pizza or pasta?" does not imply that eating both is an option. This is of course related to why the famous joke "Is it a boy or a girl? Yes." is so hilarious.

One way to make the or inclusive is to use the construct and/or.
Post reply on HN