├── README.md ├── textonly.md └── if-then-else.md /README.md: -------------------------------------------------------------------------------- 1 | if-then-else 2 | ============ 3 | 4 | [Video](https://www.youtube.com/watch?v=4A94JsWTXXw) 5 | -------------------------------------------------------------------------------- /textonly.md: -------------------------------------------------------------------------------- 1 | 2 | Hi, I'm Eric. I'm here to talk about what seems like an absurd idea: 3 | that if-then-else had to be invented. 4 | 5 | --- 6 | 7 | 8 | If-then-else is how we talk about conditions in programming languages: 9 | if something is true, then do a thing, else do a different thing. 10 | 11 | That's just English, right? Except that it isn't. 12 | I can't use "else" as a conjunction in normal speech, 13 | only in computer programs. 14 | 15 | Where did this `else` come from? It's a mystery. 16 | It's too microscopic a detail to have made it 17 | into books on the history of programming languages. 18 | 19 | --- 20 | 21 | 22 | It doesn't seem to have come from surveys or legal proceedings or algorithms 23 | as they were written before there were computers. You find "if yes" and "if no" 24 | and "if however", but not "else". 25 | 26 | * https://books.google.com/books?id=AH9Fs8huUGsC&pg=PA46#v=onepage&q&f=false 27 | * https://archive.org/details/actsstateohio39statgoog/page/n189 28 | * https://archive.org/details/in.ernet.dli.2015.463129/page/n85 29 | 30 | --- 31 | 32 | 33 | The first computer to be able to perform different instructions 34 | depending on the result of a previous calculation seems to have been the Eniac. 35 | In 1946, Haskell Curry and Willa Wyatt wrote this report describing a program 36 | to invert a function. They used the name "discrimination" for the 37 | facility of making a decision based on which of two numbers was larger. 38 | 39 | * https://apps.dtic.mil/dtic/tr/fulltext/u2/640621.pdf 40 | 41 | --- 42 | 43 | 44 | The Eniac did not have an instruction called "discriminate." 45 | It was programmed by wires and dials on plugboards, and the 46 | control panel for the instruction that made a calculation for 47 | a decision was connected by physical wires to the instructions 48 | that could follow it. 49 | 50 | Soon computers began to have enough memory that programs could be 51 | stored in memory instead of wired together. Instead of a physical 52 | sequence of instructions, there was a numerical sequence. 53 | A few special instructions could cause the computer to jump 54 | to a different point in the sequence. 55 | 56 | * http://www.columbia.edu/cu/computinghistory/eniac.html 57 | 58 | --- 59 | 60 | 61 | Here, for example, is the conditional jump instruction from one of 62 | the first commercially produced computers. It checked whether the 63 | last number calculated was negative. If so, it diverted the flow of 64 | control to some specified location in memory; otherwise, it let control 65 | continue to the next instruction. 66 | 67 | It was meant for a specific usage pattern: if you wanted to do a task, 68 | say, 10 times, your program counted how many times it had done it so far 69 | and then subtracted 10. If the result was negative, the task wasn't 70 | done, so it jumped back to do another round. 71 | 72 | * http://s3data.computerhistory.org/brochures/eckertmauchly.binac.1949.102646200.pdf 73 | 74 | --- 75 | 76 | 77 | The idea was carried forward into the first higher-level 78 | programming languages, like Halcombe Laning and Neal Zierler's 79 | language for Whirlwind. Their conditional jump worked the same way, 80 | except that the numbered steps of the program were algebraic 81 | expressions, not single machine instructions. 82 | 83 | * https://archive.computerhistory.org/resources/text/Fortran/102653982.05.01.acc.pdf 84 | 85 | --- 86 | 87 | 88 | The first popular programming language, Fortran, generalized the idea 89 | by specifying jumps to three locations at once, depending on whether 90 | a calculation was negative, zero, or positive, and gave it the name "if." 91 | 92 | The three-way "if" was more powerful than just checking for a negative, 93 | but was probably more confusing, because every decision meant 94 | a discontinuity in the control flow instead of programmers only having 95 | to think about the normal case that continued on and the unusual case 96 | that jumped. 97 | 98 | * https://www.fortran.com/FortranForTheIBM704.pdf 99 | 100 | --- 101 | 102 | 103 | Flow-Matic, Grace Murray Hopper's predecessor to COBOL, made the three-way if 104 | a little easier to think about by talking about comparing two numbers instead 105 | of about the signs of numbers. It introduced the name "otherwise" for 106 | the case where the comparison wasn't what you were looking for. 107 | 108 | * https://archive.org/details/bitsavers_univacflowProgrammingSystem1958_9367413/page/n39 109 | 110 | --- 111 | 112 | 113 | All these programming languages were associated with one particular computer 114 | from one particular manufacturer. In 1958, two American and German computing 115 | organizations began a joint project to develop a standard machine-independent 116 | language, one that would be natural for people to talk about rather than natural 117 | to implement on some particular machine. Each group brought a draft proposal 118 | to the joint conference. 119 | 120 | * https://dl.acm.org/citation.cfm?id=800025 121 | 122 | --- 123 | 124 | 125 | The German authors made two big conceptual leaps in their formulation of 126 | the "if" statement. 127 | 128 | The first was to let the conditional be controlled by any boolean expression 129 | rather than giving special priority to the less-than/equal/greater-than form. 130 | 131 | --- 132 | 133 | 134 | The second big leap was that instead of causing an abrupt jump in 135 | the flow of control, their "if" statement only caused the flow to be 136 | temporarily diverted. At the end of the condition, whether the condition 137 | had been true or false, the program would resume at the "always" statement 138 | at the end of the block. The only difference would be whether the 139 | subsidiary statements had been performed. 140 | 141 | The example on screen shows two "ifs" in a single block, and you might 142 | think that the second one was intended to work as an "else if" does now. But 143 | they expected all the conditions to be evaluated, even if one had already 144 | been found to be true. So if the statements controlled by the first 145 | changed a value that the second comparison depended upon, both blocks 146 | of statements might execute. 147 | 148 | * http://www.softwarepreservation.org/projects/ALGOL/report/BauerBRS-Proposal_for_a_Universal_Language-1958.pdf 149 | 150 | --- 151 | 152 | 153 | Where the German proposal did have something like "else" was in a 154 | second, entirely different, conditional form called "case." 155 | Unlike "case" as we know it now, their "case" was another way 156 | of writing boolean conditions, with the conditions set apart 157 | in a separate block from the statements they controlled. 158 | It sounds like they thought this form would be easier for 159 | more complicated comparisons. 160 | 161 | And here is the first appearance of the world "else," for the 162 | case where none of the other cases apply. 163 | 164 | * http://www.softwarepreservation.org/projects/ALGOL/report/BauerBRS-Proposal_for_a_Universal_Language-1958.pdf 165 | 166 | --- 167 | 168 | 169 | Why did they call it "else?" They don't say. 170 | 171 | What they do say is that this document was originally written in German 172 | and hastily translated into English. 173 | I think a carefully-chosen German word 174 | was probably translated as an archaic English word and then never revisited. 175 | Unfortunately we do not have the original German text to consult. 176 | 177 | * http://www.softwarepreservation.org/projects/ALGOL/report/BauerBRS-Proposal_for_a_Universal_Language-1958.pdf 178 | 179 | --- 180 | 181 | 182 | The American proposal also had the idea of controlling statements 183 | by boolean expressions. It didn't even have an "if" keyword. 184 | Instead, if an expression was followed by an arrow, the expression controlled 185 | the statements that followed the arrow. 186 | 187 | The notation doesn't make it obvious, but unlike the German block of ifs, 188 | in the American form, if one expression in a block evaluated to true, 189 | it did short-circuit and skip the following expressions, like "else if" 190 | does now. 191 | 192 | * http://www.softwarepreservation.org/projects/ALGOL/report/ACM_ALGOL_Proposal_1958.pdf 193 | 194 | --- 195 | 196 | 197 | The two organizations held a joint meeting and merged their proposals 198 | into a single document that they called the International Algebraic Language. 199 | Before long the language would be renamed to Algol. 200 | 201 | The "if" statement in the combined document looks a lot like the 202 | German proposal, but eliminates the "always" statement to end the block. 203 | Instead, each "if" stands alone, and if you want multiple statements 204 | to be controlled by the same expression, you can use "begin" and "end" 205 | to group them together. 206 | 207 | There is nothing like "else" in this formulation of "if." 208 | 209 | * http://www.softwarepreservation.org/projects/ALGOL/report/Algol58_preliminary_report_CACM.pdf 210 | 211 | --- 212 | 213 | 214 | However, Algol 58 also had a second conditional form, called "if either." 215 | In this form, you could say "or if" to do the same thing as we now do 216 | with "else if." But there is nothing equivalent to "else" by itself, 217 | without another "if." 218 | 219 | * http://www.softwarepreservation.org/projects/ALGOL/report/Algol58_preliminary_report_CACM.pdf 220 | 221 | --- 222 | 223 | 224 | The story gets muddy the next year, when several papers about Algol 225 | were presented at a conference. One of them was the paper where John Backus, 226 | who had previously led the Fortran project, introduced the idea of formal 227 | grammars for programming languages. 228 | 229 | Algol as he describes it doesn't have the "if either" conditional form. 230 | Instead, it has a keyword called "converge," which makes the top-level 231 | "ifs" inside its block behave like "else ifs." It is not clear whether 232 | this was meant as an idea for a better "if either," or whether it was an earlier 233 | idea that had already been rejected in favor of "if either." 234 | 235 | * http://www.softwarepreservation.org/projects/ALGOL/paper/Backus-ICIP-1959.pdf 236 | 237 | --- 238 | 239 | 240 | Either way, "if either" would soon be replaced. In 1957 John McCarthy 241 | at MIT had written a proposal for the project that became LISP, 242 | another extremely old programming language that still survives today. 243 | His proposal introduced the idea of the conditional expression, 244 | as opposed to the conditional statement. 245 | 246 | The important distinction is that an expression must always have a value, 247 | while a statement can simply not be performed if the condition that controls 248 | it is not true. 249 | 250 | So his "if function" always ends with a clause called "otherwise" 251 | that gives the value of the expression when none of the other 252 | conditions have evaluated to true. 253 | 254 | * http://www.softwarepreservation.org/projects/LISP/MIT/McCarthy-CC-56.pdf 255 | 256 | --- 257 | 258 | 259 | McCarthy's conditional expressions inspired Klaus Samelson to clean up 260 | and unify Algol's two separate conditional models at the end 261 | of 1959. He eliminated the entire "if either" form, leaving 262 | only the plain "if," but added a clause called "else" that would 263 | be performed when the expression controlling the corresponding "if" 264 | had been false. 265 | 266 | You could chain conditions together with "else if," just like 267 | the previous "if either" had allowed with "or if," but you could 268 | also use "else" by itself for a final set of statements that 269 | would run if none of the conditions had been true. 270 | 271 | * https://dl.acm.org/citation.cfm?id=1060889 272 | 273 | --- 274 | 275 | 276 | "If-then-else" was the single conditional form that appeared in the Algol 60 277 | report the next year, and is the form that almost all subsequent 278 | programming languages have followed. 279 | 280 | Although it seems clear to us now, it was hard for people in 1960 to think about, 281 | and the report spends a page and a half explaining how it works, 282 | including this arrow diagram. 283 | 284 | * https://fi.ort.edu.uy/innovaportal/file/20124/1/14-naure_algol60.pdf 285 | 286 | --- 287 | 288 | 289 | As I mentioned, the use of "else" as a conjuction sounds strange. 290 | Christopher Strachey's CPL programming language is the grandparent 291 | of C and therefore the ancestor of most current programming languages, 292 | and he refused to use "else," calling it "ignorantly incorrect English." 293 | He thought we should write "test … then … or" instead, which also 294 | doesn't sound very natural, and didn't catch on. 295 | 296 | * http://www.ancientgeek.org.uk/CPL/CPL_Elementary_Programming_Manual.pdf 297 | 298 | --- 299 | 300 | 301 | The MAD programming language also went its own way. It was known 302 | for its extremely long keywords, and in addition to using 303 | "whenever" instead of "if," it used "otherwise" instead of "else" 304 | and "or whenever" instead of "else if." 305 | 306 | It is worth nothing the indentation in the MAD manual's example. 307 | It took years before most other programming languages adopted 308 | this style of indenting conditions, even though it now 309 | seems unimaginable to do it any other way. 310 | 311 | * http://www.bitsavers.org/pdf/univOfMichigan/mad/L2-UOI-MAD1-2-RX_MADum_62.pdf 312 | 313 | --- 314 | 315 | 316 | But even while CPL and MAD shunned the word "else," they kept 317 | the form and only changed the vocabulary. Language designers still search 318 | for the perfect way to write a `for` loop, but the quest for 319 | the perfect conditional form seems to have ended in 1959. 320 | Thank you Klaus Samelson, for giving us a tool to think with 321 | and a word to puzzle over. 322 | 323 | * https://www.in.tum.de/en/the-department/history/ 324 | -------------------------------------------------------------------------------- /if-then-else.md: -------------------------------------------------------------------------------- 1 | [Video](https://www.youtube.com/watch?v=4A94JsWTXXw) 2 | 3 | --- 4 | 5 | ![01](https://user-images.githubusercontent.com/1951835/53196872-e0f17880-35cd-11e9-86ce-f832c4d3e00e.png) 6 | 7 | Hi, I'm Eric. I'm here to talk about what seems like an absurd idea: 8 | that if-then-else had to be invented. 9 | 10 | --- 11 | 12 | ![02](https://user-images.githubusercontent.com/1951835/53196889-ed75d100-35cd-11e9-8d4c-c5fbf76c2dfc.png) 13 | 14 | If-then-else is how we talk about conditions in programming languages: 15 | if something is true, then do a thing, else do a different thing. 16 | 17 | That's just English, right? Except that it isn't. 18 | I can't use "else" as a conjunction in normal speech, 19 | only in computer programs. 20 | 21 | Where did this `else` come from? It's a mystery. 22 | It's too microscopic a detail to have made it 23 | into books on the history of programming languages. 24 | 25 | --- 26 | 27 | ![03](https://user-images.githubusercontent.com/1951835/53279381-bb936600-36c4-11e9-83ae-53858a8319a2.png) 28 | 29 | It doesn't seem to have come from surveys or legal proceedings or algorithms 30 | as they were written before there were computers. You find "if yes" and "if no" 31 | and "if however", but not "else". 32 | 33 | * https://books.google.com/books?id=AH9Fs8huUGsC&pg=PA46#v=onepage&q&f=false 34 | * https://archive.org/details/actsstateohio39statgoog/page/n189 35 | * https://archive.org/details/in.ernet.dli.2015.463129/page/n85 36 | 37 | --- 38 | 39 | ![05](https://user-images.githubusercontent.com/1951835/53196928-03839180-35ce-11e9-87e5-6a99846479ec.png) 40 | 41 | The first computer to be able to perform different instructions 42 | depending on the result of a previous calculation seems to have been the Eniac. 43 | In 1946, Haskell Curry and Willa Wyatt wrote this report describing a program 44 | to invert a function. They used the name "discrimination" for the 45 | facility of making a decision based on which of two numbers was larger. 46 | 47 | * https://apps.dtic.mil/dtic/tr/fulltext/u2/640621.pdf 48 | 49 | --- 50 | 51 | ![06](https://user-images.githubusercontent.com/1951835/53196947-0c746300-35ce-11e9-8db7-2e8f0fc2e1d8.png) 52 | 53 | The Eniac did not have an instruction called "discriminate." 54 | It was programmed by wires and dials on plugboards, and the 55 | control panel for the instruction that made a calculation for 56 | a decision was connected by physical wires to the instructions 57 | that could follow it. 58 | 59 | Soon computers began to have enough memory that programs could be 60 | stored in memory instead of wired together. Instead of a physical 61 | sequence of instructions, there was a numerical sequence. 62 | A few special instructions could cause the computer to jump 63 | to a different point in the sequence. 64 | 65 | * http://www.columbia.edu/cu/computinghistory/eniac.html 66 | 67 | --- 68 | 69 | ![07](https://user-images.githubusercontent.com/1951835/53197002-27df6e00-35ce-11e9-82b4-8f0085b79a31.png) 70 | 71 | Here, for example, is the conditional jump instruction from one of 72 | the first commercially produced computers. It checked whether the 73 | last number calculated was negative. If so, it diverted the flow of 74 | control to some specified location in memory; otherwise, it let control 75 | continue to the next instruction. 76 | 77 | It was meant for a specific usage pattern: if you wanted to do a task, 78 | say, 10 times, your program counted how many times it had done it so far 79 | and then subtracted 10. If the result was negative, the task wasn't 80 | done, so it jumped back to do another round. 81 | 82 | * http://s3data.computerhistory.org/brochures/eckertmauchly.binac.1949.102646200.pdf 83 | 84 | --- 85 | 86 | ![08](https://user-images.githubusercontent.com/1951835/53197024-3037a900-35ce-11e9-9813-dc2f2d5a5c2b.png) 87 | 88 | The idea was carried forward into the first higher-level 89 | programming languages, like Halcombe Laning and Neal Zierler's 90 | language for Whirlwind. Their conditional jump worked the same way, 91 | except that the numbered steps of the program were algebraic 92 | expressions, not single machine instructions. 93 | 94 | * https://archive.computerhistory.org/resources/text/Fortran/102653982.05.01.acc.pdf 95 | 96 | --- 97 | 98 | ![09](https://user-images.githubusercontent.com/1951835/53197039-362d8a00-35ce-11e9-8099-b1597edc5f97.png) 99 | 100 | The first popular programming language, Fortran, generalized the idea 101 | by specifying jumps to three locations at once, depending on whether 102 | a calculation was negative, zero, or positive, and gave it the name "if." 103 | 104 | The three-way "if" was more powerful than just checking for a negative, 105 | but was probably more confusing, because every decision meant 106 | a discontinuity in the control flow instead of programmers only having 107 | to think about the normal case that continued on and the unusual case 108 | that jumped. 109 | 110 | * https://www.fortran.com/FortranForTheIBM704.pdf 111 | 112 | --- 113 | 114 | ![10](https://user-images.githubusercontent.com/1951835/53197053-3ded2e80-35ce-11e9-9fb6-d46dcb793984.png) 115 | 116 | Flow-Matic, Grace Murray Hopper's predecessor to COBOL, made the three-way if 117 | a little easier to think about by talking about comparing two numbers instead 118 | of about the signs of numbers. It introduced the name "otherwise" for 119 | the case where the comparison wasn't what you were looking for. 120 | 121 | * https://archive.org/details/bitsavers_univacflowProgrammingSystem1958_9367413/page/n39 122 | 123 | --- 124 | 125 | ![algol](https://user-images.githubusercontent.com/1951835/53220700-bf6aae00-361a-11e9-835d-27b359b4fb14.png) 126 | 127 | All these programming languages were associated with one particular computer 128 | from one particular manufacturer. In 1958, two American and German computing 129 | organizations began a joint project to develop a standard machine-independent 130 | language, one that would be natural for people to talk about rather than natural 131 | to implement on some particular machine. Each group brought a draft proposal 132 | to the joint conference. 133 | 134 | * https://dl.acm.org/citation.cfm?id=800025 135 | 136 | --- 137 | 138 | ![11](https://user-images.githubusercontent.com/1951835/53227239-9524ea80-3632-11e9-927e-16e887a186a4.png) 139 | 140 | The German authors made two big conceptual leaps in their formulation of 141 | the "if" statement. 142 | 143 | The first was to let the conditional be controlled by any boolean expression 144 | rather than giving special priority to the less-than/equal/greater-than form. 145 | 146 | --- 147 | 148 | ![11](https://user-images.githubusercontent.com/1951835/53197069-46456980-35ce-11e9-97a5-fd646c4bee15.png) 149 | 150 | The second big leap was that instead of causing an abrupt jump in 151 | the flow of control, their "if" statement only caused the flow to be 152 | temporarily diverted. At the end of the condition, whether the condition 153 | had been true or false, the program would resume at the "always" statement 154 | at the end of the block. The only difference would be whether the 155 | subsidiary statements had been performed. 156 | 157 | The example on screen shows two "ifs" in a single block, and you might 158 | think that the second one was intended to work as an "else if" does now. But 159 | they expected all the conditions to be evaluated, even if one had already 160 | been found to be true. So if the statements controlled by the first 161 | changed a value that the second comparison depended upon, both blocks 162 | of statements might execute. 163 | 164 | * http://www.softwarepreservation.org/projects/ALGOL/report/BauerBRS-Proposal_for_a_Universal_Language-1958.pdf 165 | 166 | --- 167 | 168 | ![12](https://user-images.githubusercontent.com/1951835/53197081-4d6c7780-35ce-11e9-92f7-f60bc220301f.png) 169 | 170 | Where the German proposal did have something like "else" was in a 171 | second, entirely different, conditional form called "case." 172 | Unlike "case" as we know it now, their "case" was another way 173 | of writing boolean conditions, with the conditions set apart 174 | in a separate block from the statements they controlled. 175 | It sounds like they thought this form would be easier for 176 | more complicated comparisons. 177 | 178 | And here is the first appearance of the world "else," for the 179 | case where none of the other cases apply. 180 | 181 | * http://www.softwarepreservation.org/projects/ALGOL/report/BauerBRS-Proposal_for_a_Universal_Language-1958.pdf 182 | 183 | --- 184 | 185 | ![13](https://user-images.githubusercontent.com/1951835/53197096-54938580-35ce-11e9-8371-15fd57575ab1.png) 186 | 187 | Why did they call it "else?" They don't say. 188 | 189 | What they do say is that this document was originally written in German 190 | and hastily translated into English. 191 | I think a carefully-chosen German word 192 | was probably translated as an archaic English word and then never revisited. 193 | Unfortunately we do not have the original German text to consult. 194 | 195 | * http://www.softwarepreservation.org/projects/ALGOL/report/BauerBRS-Proposal_for_a_Universal_Language-1958.pdf 196 | 197 | --- 198 | 199 | ![14](https://user-images.githubusercontent.com/1951835/53197793-cd471180-35cf-11e9-8fd5-7b032e01228d.png) 200 | 201 | The American proposal also had the idea of controlling statements 202 | by boolean expressions. It didn't even have an "if" keyword. 203 | Instead, if an expression was followed by an arrow, the expression controlled 204 | the statements that followed the arrow. 205 | 206 | The notation doesn't make it obvious, but unlike the German block of ifs, 207 | in the American form, if one expression in a block evaluated to true, 208 | it did short-circuit and skip the following expressions, like "else if" 209 | does now. 210 | 211 | * http://www.softwarepreservation.org/projects/ALGOL/report/ACM_ALGOL_Proposal_1958.pdf 212 | 213 | --- 214 | 215 | ![15](https://user-images.githubusercontent.com/1951835/53197122-62e1a180-35ce-11e9-9f26-63c87e6687b4.png) 216 | 217 | The two organizations held a joint meeting and merged their proposals 218 | into a single document that they called the International Algebraic Language. 219 | Before long the language would be renamed to Algol. 220 | 221 | The "if" statement in the combined document looks a lot like the 222 | German proposal, but eliminates the "always" statement to end the block. 223 | Instead, each "if" stands alone, and if you want multiple statements 224 | to be controlled by the same expression, you can use "begin" and "end" 225 | to group them together. 226 | 227 | There is nothing like "else" in this formulation of "if." 228 | 229 | * http://www.softwarepreservation.org/projects/ALGOL/report/Algol58_preliminary_report_CACM.pdf 230 | 231 | --- 232 | 233 | ![16](https://user-images.githubusercontent.com/1951835/53197134-6aa14600-35ce-11e9-9312-9332ca7b8184.png) 234 | 235 | However, Algol 58 also had a second conditional form, called "if either." 236 | In this form, you could say "or if" to do the same thing as we now do 237 | with "else if." But there is nothing equivalent to "else" by itself, 238 | without another "if." 239 | 240 | * http://www.softwarepreservation.org/projects/ALGOL/report/Algol58_preliminary_report_CACM.pdf 241 | 242 | --- 243 | 244 | ![17](https://user-images.githubusercontent.com/1951835/53197144-71c85400-35ce-11e9-99ac-1ed3f1dc165c.png) 245 | 246 | The story gets muddy the next year, when several papers about Algol 247 | were presented at a conference. One of them was the paper where John Backus, 248 | who had previously led the Fortran project, introduced the idea of formal 249 | grammars for programming languages. 250 | 251 | Algol as he describes it doesn't have the "if either" conditional form. 252 | Instead, it has a keyword called "converge," which makes the top-level 253 | "ifs" inside its block behave like "else ifs." It is not clear whether 254 | this was meant as an idea for a better "if either," or whether it was an earlier 255 | idea that had already been rejected in favor of "if either." 256 | 257 | * http://www.softwarepreservation.org/projects/ALGOL/paper/Backus-ICIP-1959.pdf 258 | 259 | --- 260 | 261 | ![18](https://user-images.githubusercontent.com/1951835/53197164-7bea5280-35ce-11e9-92eb-6dd24abf3967.png) 262 | 263 | Either way, "if either" would soon be replaced. In 1957 John McCarthy 264 | at MIT had written a proposal for the project that became LISP, 265 | another extremely old programming language that still survives today. 266 | His proposal introduced the idea of the conditional expression, 267 | as opposed to the conditional statement. 268 | 269 | The important distinction is that an expression must always have a value, 270 | while a statement can simply not be performed if the condition that controls 271 | it is not true. 272 | 273 | So his "if function" always ends with a clause called "otherwise" 274 | that gives the value of the expression when none of the other 275 | conditions have evaluated to true. 276 | 277 | * http://www.softwarepreservation.org/projects/LISP/MIT/McCarthy-CC-56.pdf 278 | 279 | --- 280 | 281 | ![20](https://user-images.githubusercontent.com/1951835/53279391-c817be80-36c4-11e9-8fa5-fd1df6942fdf.png) 282 | 283 | McCarthy's conditional expressions inspired Klaus Samelson to clean up 284 | and unify Algol's two separate conditional models at the end 285 | of 1959. He eliminated the entire "if either" form, leaving 286 | only the plain "if," but added a clause called "else" that would 287 | be performed when the expression controlling the corresponding "if" 288 | had been false. 289 | 290 | You could chain conditions together with "else if," just like 291 | the previous "if either" had allowed with "or if," but you could 292 | also use "else" by itself for a final set of statements that 293 | would run if none of the conditions had been true. 294 | 295 | * https://dl.acm.org/citation.cfm?id=1060889 296 | 297 | --- 298 | 299 | ![20](https://user-images.githubusercontent.com/1951835/53197180-83116080-35ce-11e9-85c2-ff53a345a4e5.png) 300 | 301 | "If-then-else" was the single conditional form that appeared in the Algol 60 302 | report the next year, and is the form that almost all subsequent 303 | programming languages have followed. 304 | 305 | Although it seems clear to us now, it was hard for people in 1960 to think about, 306 | and the report spends a page and a half explaining how it works, 307 | including this arrow diagram. 308 | 309 | * https://fi.ort.edu.uy/innovaportal/file/20124/1/14-naure_algol60.pdf 310 | 311 | --- 312 | 313 | ![21](https://user-images.githubusercontent.com/1951835/53197193-899fd800-35ce-11e9-9605-2da38f85c006.png) 314 | 315 | As I mentioned, the use of "else" as a conjuction sounds strange. 316 | Christopher Strachey's CPL programming language is the grandparent 317 | of C and therefore the ancestor of most current programming languages, 318 | and he refused to use "else," calling it "ignorantly incorrect English." 319 | He thought we should write "test … then … or" instead, which also 320 | doesn't sound very natural, and didn't catch on. 321 | 322 | * http://www.ancientgeek.org.uk/CPL/CPL_Elementary_Programming_Manual.pdf 323 | * https://www.computer.org/csdl/mags/an/2013/03/06231610.pdf 324 | 325 | --- 326 | 327 | ![22](https://user-images.githubusercontent.com/1951835/53197217-91f81300-35ce-11e9-863b-5a017834f510.png) 328 | 329 | The MAD programming language also went its own way. It was known 330 | for its extremely long keywords, and in addition to using 331 | "whenever" instead of "if," it used "otherwise" instead of "else" 332 | and "or whenever" instead of "else if." 333 | 334 | It is worth noting the indentation in the MAD manual's example. 335 | It took years before most other programming languages adopted 336 | this style of indenting conditions, even though it now 337 | seems unimaginable to do it any other way. 338 | 339 | * http://www.bitsavers.org/pdf/univOfMichigan/mad/L2-UOI-MAD1-2-RX_MADum_62.pdf 340 | 341 | --- 342 | 343 | ![24](https://user-images.githubusercontent.com/1951835/53279397-d1089000-36c4-11e9-8582-fa90f64837a7.png) 344 | 345 | But even while CPL and MAD shunned the word "else," they kept 346 | the form and only changed the vocabulary. Language designers still search 347 | for the perfect way to write a `for` loop, but the quest for 348 | the perfect conditional form seems to have ended in 1959. 349 | Thank you Klaus Samelson, for giving us a tool to think with 350 | and a word to puzzle over. 351 | 352 | * https://www.in.tum.de/en/the-department/history/ 353 | --------------------------------------------------------------------------------