Re:if...then...else had to be invented (2019)
by todd8 on Sunday December 13, 2020 @06:18AM
(#25405782)
For 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.
Re:if...then...else had to be invented (2019)
by ThePadawan on Sunday December 13, 2020 @06:39AM
(#25405859)
Shame 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").
Re:if...then...else had to be invented (2019)
by flohofwoe on Sunday December 13, 2020 @07:21AM
(#25406093)
Yeah, 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" ;)
Re:if...then...else had to be invented (2019)
by llimos on Sunday December 13, 2020 @07:54AM
(#25406249)
This 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.
Re:if...then...else had to be invented (2019)
by llimos on Sunday December 13, 2020 @03:25PM
(#25409883)
Right. 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.)
Re:if...then...else had to be invented (2019)
by Philadelphia on Sunday December 13, 2020 @03:52PM
(#25410142)
It’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.
Re:if...then...else had to be invented (2019)
by jamesmehaffey on Sunday December 13, 2020 @04:25PM
(#25410442)
No 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.
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:
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
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").
This makes less sense, though, in a language that permits fall-through or putting 'default' in the middle of the switch statement.
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.
“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-el...
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.)
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.
https://news.ycombinator.com/item?id=25406211