4 ms·
if...then...else had to be invented (2019)
- ExcavateGrandMa 6y agohttps://user-images.githubusercontent.com/1951835/53196928-03839180-35ce-11e9-87e5-6a99846479ec.png https://user-images.githubusercontent.com/1951835/53196928-0... It's like over the time I discover that smart ppl are fully aware/conscious what they do. :)
- todd8 6y agoFor my first few years programming I never used a statement of the form if ... else ... In late 1967, I taught myself to program. I never saw a computer during that time, but my high school owned a IBM 026 Keypunch machine used by the administration to enter data that was sent downtown to the school district that had a computer. I would use the keypunch machine to punch my program onto cards, one card per line of code. A friend of mine would pass them along to be run on the district’s computer. The programming language that I had available was FORTRAN II. It had the arithmetic if and the goto but no modern if statement. The if looked like this: IF (2*I - K) 25,35,55 Which meant compute the expression, if the result is negative jump to line with label 25, if result is zero jump to line of code with label 35, and if result is positive jump to line 55. There were no Booleans, no comparison operators, and no modern control structures. My very first attempt to program was intended to solve linear programming optimization problems using the Simplex algorithm, see [1]. The Simplex method finds optimal solutions to a multi variate linear expression, given a set of constraints expressed as inequalities on linear expressions over subsets of the free variables. I had read a slim book on the Simplex method and naively believed that it was a suitable first program. The turn around time submitting a program for me back then was about one week. Despite this ridiculous first attempt at programming, I scaled back my ambitions and wrote ten or twenty simple programs in FORTRAN without an else before going off to college to study mathematics. It was a much simpler time to tinker with computers, I was excited to see my programs print simple tabular answers on fanfold paper. [1] https://en.m.wikipedia.org/wiki/Simplex_algorithm https://en.m.wikipedia.org/wiki/Simplex_algorithm
- ThePadawan 6y agoShame that the original German text was lost, now all I can do is hazard a guess: Most German words with the meaning of "otherwise" are pretty long/verbose: "andernfalls" (literally: other-case-d), "ansonsten" (literally: on-others). "sonst" (short for "ansonsten") might have made an appearance, and I'm struggling to find an English word as short as that (that isn't "else").
- flohofwoe 6y agoYeah, I bet the mysterious German word was "sonst". "wenn-dann-sonst" ("if-then-else") totally makes sense in German, but also as the default-case in a switch-case-like statement (which is the context mentioned in the article). From that point of view it's a bit of a shame that "switch-case-default" didn't end up as "switch-case-else" ;)
- Cpoll 6y ago> From that point of view it's a bit of a shame that "switch-case-default" didn't end up as "switch-case-else" ;) This makes less sense, though, in a language that permits fall-through or putting 'default' in the middle of the switch statement.
- llimos 6y agoThis blew my mind. Not the answer, but the question - I'm a native English speaker, how did I never notice that else makes no sense? Clearly I've been programming for far too long :) EDIT: Thinking about it a bit more, "or else" is valid English, although not ususally following "if". More like, "Do this, or else I will...". Perhaps it was supposed to be "or else", and "or" was already a keyword so we're left with "else"? But it still doesn't follow well from "if" so the bad translation from German (possibly using a dictionary) is still more likely.
- Philadelphia 6y agoIt’s a common and accepted construction in English “or else used to say what will happen if another thing does not happen: We must be there by six, or else we'll miss the beginning” https://dictionary.cambridge.org/us/dictionary/english/or-else https://dictionary.cambridge.org/us/dictionary/english/or-el...
- llimos 6y agoRight. But I can't think of a good sentence that starts with 'if' and contains 'or else'. It could be that the 'if' is implied if you say 'or else'. But 'otherwise' works fine following 'if' and it would probably have been better if they stuck to that. (Albeit lots more keystrokes - but as keywords go it's shorter than 'instanceof' and people don't complain about that one.)
- Philadelphia 6y agoIt’s more the concept than the grammar. You do this, or else you do that. instanceof is very new. At the time of if/else, there wasn’t anything nearly that long. It’s even too long for a filename on many computers of the era.
- pieterr 6y agoDuplicate? https://news.ycombinator.com/item?id=25406211 https://news.ycombinator.com/item?id=25406211
- BearOso 6y agoCould be short for elsewise, maybe? Else has the fewest characters—that’s likely the reason it panned out.
- jamesmehaffey 6y agoNo one ever said that programmers were poets. It seems like they were just trying to get their point across while saving keystrokes, but it seems funny that something so simple and obvious occupied so much of their attention.