Live data from Hacker News

If-then-else had to be invented

github.com

71–80 of 255 posts

Re: If-then-else had to be invented

#71
post #63

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.

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

[deleted]

Re: If-then-else had to be invented

#72

If the question is, what was the first programming language that introduced "If-then-else" then the read makes sense, but I'm not sure if was really an inventive step. In propositional logic, which was developed well before the first computers by Leibniz, Frege, Boole, De Morgan, etc.: "If A then B else C" can be stated as: (A --> B) ^ (¬A --> C) So, in patent/invention language, I'm not sure if it would really const…

You should add that to Wikipedia: https://en.m.wikipedia.org/wiki/Conditional_(computer_progra...

Re: If-then-else had to be invented

#73

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

Interestingly your index based loop example is the opposite of how shell scripting works. That is a lot more like a human language in its construct:

   candy | kids
Where candy and kids are self contained programs that already understand the operations which make up candy and kids.

Re: If-then-else had to be invented

#74

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.

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

Re: If-then-else had to be invented

#75
post #8
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.

Wiktionary has a usage example from 1903, clearly before modern computers but not too ancient. > 1903, Jack London, The Call of the Wild, Grosset & Dunlap, page 44: > […] and his first experience taught him an unforgetable lesson. It is true, it was a vicarious experience, else he would not have lived to profit by it. As an aside there is at least one common word which does seem to have been invented by the software…

> "access" as a verb

The comic Calvin & Hobbes corroborates the novelty of this verb in this strip from 1993: https://www.gocomics.com/calvinandhobbes/1993/01/25

Re: If-then-else had to be invented

#76
post #63

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.

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

coordinating conjunctions are wierd. and, or, for, but, yet, so, nor. Nor is sort of an oddball there, since it continues negated clauses, well I use it to. - my jeans were neither creased nor dirty. Yet fits in a ton of places as well.

Re: If-then-else had to be invented

#77

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.

I would say that in every case there is a set of things (maybe with a single member) and a set of predicates (maybe with a single member), a mapping from the things to the predicates, and every mapping produces a true proposition.

"Women and children were present" isn't saying the intersection of the women and children were present but that the things were women and children and they all were present.

The rest of the variety of "meanings" of "and" are just inferences on top of this basic meaning. If things occur in sequence, for instance, we can infer causality from what we know about the things conjoined apart from the conjunction.

Crucially, there is more here than just "joining multiple clauses together" (and many of the things conjoined aren't clauses), because "or" can be described this way too, but "and" does not mean the same thing as "or". With "or" you are only asserting that some of the propositions are true.

Re: If-then-else had to be invented

#78

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.

This is correct. The technical word linguists use for the role words like "and" play is coordination.

https://en.wikipedia.org/wiki/Coordination_(linguistics)

Re: If-then-else had to be invented

#79

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.

What is wrong with a yes response to "do you want to eat pizza or pasta?" with yes implying that one would be willing to eat either rather than requiring an exclusive preference that could be asked with "either" before pizza? Similarly with the boy or girl question, "no" may be stillborn.

Re: If-then-else had to be invented

#80

If the question is, what was the first programming language that introduced "If-then-else" then the read makes sense, but I'm not sure if was really an inventive step. In propositional logic, which was developed well before the first computers by Leibniz, Frege, Boole, De Morgan, etc.: "If A then B else C" can be stated as: (A --> B) ^ (¬A --> C) So, in patent/invention language, I'm not sure if it would really const…

McCarthy published a paper in 1961 about if-then-else as a form of propositional logic replacing and/or/not, with its own identities playing a role like associativity, de Morgan's laws, etc. This had to be invented.

It's interesting to me that these identities and the canonical form McCarthy introduced there were exactly how BDDs work (when you just add memoizing, which was also invented about the same time) -- but BDDs weren't invented until the 1980s. (Explanation at https://codewords.recurse.com/issues/four/the-language-of-ch...)

It's easy to think things are obvious in hindsight.

Post reply on HN