Live data from Hacker News

If-then-else had to be invented

github.com

131–140 of 255 posts

Re: If-then-else had to be invented

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

Thanks for the insider German knowledge!

Re: If-then-else had to be invented

#132

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:…

> it's more likely you'll say something like 'give candy to these kids' or 'wash these cars' than 'give a piece of candy to each kid' or 'wash each of these cars'.

Reminds me of APL.

But I'm not sure APL can be considered being close to natural language.

Re: If-then-else had to be invented

#133

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:…

This use of "and" and "or" was inherited from mathematical logic though. It's not specific to programming languages.

Re: If-then-else had to be invented

#134
post #6

You can use "else" that way in ordinary speech. "If this then do that else do the other thing" is perfectly legitimate English, just a bit archaic.

I said I can't say it, not that no one can say it. It is not in my dialect.

Re: If-then-else had to be invented

#135

Earlier quoted context omitted.

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.

If you say it out loud, you will realize that the question "Do you want to eat pizza or pasta?" (exclusive-or case with the answer "pizza" or "pasta," i.e. in the sense "these are your two choices, which would you prefer?") is an entirely different utterance from "Do you want to eat pizza or pasta?" (inclusive-or case with the answer "yes" or "no," i.e. in the sense "would you like to go to an Italian restaurant?").…

The first one is not exclusive-or, though: if you wanted to eat pizza and pasta, you would not answer "no" to "Do you want to eat pizza or pasta?", you would answer "both". Rather, "or" is serving as a inclusive-or with (perhaps) the incidental implication that picking more than one doesn't make sense in the first place.

Re: If-then-else had to be invented

#136
post #130
post #101

> That's just English, right? Except that it isn't. I can't use "else" as a conjunction in normal speech, only in computer programs. Sure you can! Shakespeare used 'else' in the same sense as 'otherwise': https://www.shakespeareswords.com/Public/GlossaryHeadword.as... "else used as a conjunction" https://wordtype.org/of/else "Or else!" was common speech before computers, and a common vague cartoon/cowboy/sign threat.

I am the author, and I mean that I can say "or else" in a normal sentence, but I cannot say "else" without an "or" in normal speech in my normal dialect.

Wouldn't it be fair to say that it's just a shortened version of "or else"? Just like most programming languages skip "then" in "if ... then" even though it's often required for the sentence to look natural.

Re: If-then-else had to be invented

#137
post #130
post #101

> That's just English, right? Except that it isn't. I can't use "else" as a conjunction in normal speech, only in computer programs. Sure you can! Shakespeare used 'else' in the same sense as 'otherwise': https://www.shakespeareswords.com/Public/GlossaryHeadword.as... "else used as a conjunction" https://wordtype.org/of/else "Or else!" was common speech before computers, and a common vague cartoon/cowboy/sign threat.

I am the author, and I mean that I can say "or else" in a normal sentence, but I cannot say "else" without an "or" in normal speech in my normal dialect.

Maybe not in your dialect of English, but what about older dialects?

"Pay for your beer. Else, leave this place at once!"

Re: If-then-else had to be invented

#138

Earlier quoted context omitted.

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.

"This is of course related to why the famous joke "Is it a boy or a girl? Yes." is so hilarious" Only to IT people though. Common folks will just look at you in a weird way...

Except the folks are mathematicians.

But in this case there is actually a slight chance that nobody recognizes this as a joke at all...

Re: If-then-else had to be invented

#139
In the MAD example the letter O has a slash through it, and the numeral zero is unslashed. Does anyone know if this was an actual printing convention at one time? It seems backwards from how it's done today.

Re: If-then-else had to be invented

#140
I'm imagining what programming languages look like if the Axis powers won WW2. We might get many forth-like languages instead of C-like ones, since Japanese and German have subject–object–verb order.
Post reply on HN