32 ms·
If-then-else had to be invented
- codeulike 6y agoThis is fascinating! I started with BBC Basic II (on the Model B) which had IF..THEN but it was just one line and there was no ELSE. So if you wanted to make a 'block' you had to call a different PROC (thankfully there were PROCedures so you could avoid GOTO) As such when I was introduced to ELSE and ENDIF with BBC BASIC V on the Archimedes it seemed like very welcome syntactic sugar - it let you do the same stuff but in a tidier way https://en.wikipedia.org/wiki/BBC_BASIC https://en.wikipedia.org/wiki/BBC_BASIC
- ksangeelee 6y agoBBC Basic II does have ELSE, it just has to go on one line. IF A=4 THEN PRINT "FOUR" ELSE PRINT "NOT FOUR" Statements for the IF block and the ELSE block can be separated by ':'. I was recently given a BBC Micro and it's a fascinatingly impressive machine, the hardware and software are so beautifully designed in tandem that it's quite awesome even in 2020.
- codeulike 6y agoah yes you are right, the in-line ELSE Obligatory shout out for 'Micro Men', about the making of the BBC Micro and ZX Spectrum https://www.youtube.com/watch?v=XXBxV6-zamM https://www.youtube.com/watch?v=XXBxV6-zamM
- ksangeelee 6y agoFor more geeky insights into the time, I can recommend the book The ZX Spectrum ULA http://www.zxdesign.info/book/ http://www.zxdesign.info/book/ The business side of things is incidental to the rich details of the hardware design and production.
- sheeshkebab 6y agoIf/else is just as made up as for loops - it’s all if/goto underneath.
- __s 6y agoUnless you compile your program with movfuscator: https://github.com/xoreaxeaxeax/movfuscator https://github.com/xoreaxeaxeax/movfuscator Or you decide to execute code on The Fungus: https://www.bedroomlan.org/hardware/fungus https://www.bedroomlan.org/hardware/fungus I also recall reading a paper that got into implementing a GC on silicon for a graph rewriting based architecture WebAssembly is if/else blocks. There's a potential future where it gets implemented directly as a CPU ISA (albeit it'd likely involve some dynamic translation, but the CPU may decide to have SSA as its internal representation) It's important to understand there's a real distinction between semantics & implementation. Otherwise you risk emulating your implementation when some new hardware comes out (say GPUs, or Quantum computers, or out of order CPUs working backwards to create something like SSA for register renaming/pipelining, or cmov) See also the debates over C code being executed in the C abstract machine for optimizers while programmers rely on implementation of the end result. But in a language without undefined / implementation-defined behavior you won't have these ways of having the program self observe its implementation
- colejohnson66 6y ago> I also recall reading a paper that got into implementing a GC on silicon for a graph rewriting based architecture Not that, but still interesting: the Intel iAPX 432[0] was a (failed) processor from 1981 designed with high level languages in mind (specifically Ada). It supported bit-level aligned, variable length instruction, but also a built in GC and type tagging system. [0]: https://en.wikipedia.org/wiki/Intel_iAPX_432 https://en.wikipedia.org/wiki/Intel_iAPX_432
- still_grokking 6y ago> I also recall reading a paper that got into implementing a GC on silicon for a graph rewriting based architecture Maybe this one: https://github.com/tommythorn/Reduceron https://github.com/tommythorn/Reduceron
- erk__ 6y agoThis reminds me of a note in FreeBSD rc(1) man page[0] under "INCOMPATIBILITIES" > The Tenth Edition rc does not have the else keyword. Instead, if is > optionally followed by an if not clause which is executed if the pre- > ceding if test does not succeed. which i found pretty interesting [0]: https://www.freebsd.org/cgi/man.cgi?query=rc https://www.freebsd.org/cgi/man.cgi?query=rc
- goblin89 6y agoHaving taught programming to novices a little, I believe “if not” is clearer than “else”. Imagining “not” being prepended to the original conditional expression would be natural, especially in languages with “not X” construct (like Python), and it’s easy to forget that “else” is in fact archaic to non-programmer ears, slightly and possibly needlessly raising the barrier. if (X) { doY(); } if not /* X is implied */ { doZ(); } In languages like Python it could be generalized to enable one to use “if not” with an expression as usual but omit the expression if it is the last branch of a conditional, thus getting rid of the “else” keyword while maintaining or arguably improving readability. That said, there is no programming language that could entirely map to a spoken one, so perhaps it’s actually beneficial to shed any semblance of such mapping early-doors in the learning process.
- shawnz 6y agoWhat if there were 3 cases though? "Else" should exclude both of the preceding cases, but the phrasing of "If not" seems to imply it would only exclude the previous case
- goblin89 6y agoTrue! A point could be made for restricting ifs to 1 or 2 clauses and delegating more complex conditions to switch/case, but that is arguably even more far out there (and in case of Python it actually doesn’t have the switch operator). Also, “if not X {…} if not {…}” would be confusing but possible. I guess I should leave language design to the better-equipped for the time being.
- 6y ago
- BruceEel 6y agoAh, interesting, I wish the title had been prefixed with "What if ". There's a language where THEN basically means ENDIF... Forth, if memory serves me right?
- morelisp 6y agoYes, Forth is stack-based RPN so "IF" naturally comes after the test; "THEN" marks the end of the block; so if you want "ELSE" it ends up in the middle to let you nest conditions. : /CHECK DUP 0= IF ." invalid " DROP ELSE / THEN ; https://www.forth.com/starting-forth/4-conditional-if-then-statements/ https://www.forth.com/starting-forth/4-conditional-if-then-s...
- lebuffon 6y agoYes. It is used in the sense of the English statement: IF you go to the store get some butter THEN come right back. So THEN is where the program continues on a false condition. Typically Forth. It uses an alternative way of looking at things.
- MaxBarraclough 6y agoThe GForth documentation addresses this. [0] Forth is simply adopting a different use of 'then' than the one more commonly seen in programming languages, but it's still faithful to English. [0] https://gforth.org/manual/Selection.html https://gforth.org/manual/Selection.html See also the StackOverflow thread on this topic: https://stackoverflow.com/q/12539634/ https://stackoverflow.com/q/12539634/
- astrobe_ 6y agoYes, and the inventor of the language eventually removed ELSE from his dialects, amusingly. These days he says that his code has very few conditional statements. I think the tactic strategy to achieve this is to confine conditional branches in a few well chosen words. For instance if you have a word SORT that sorts the top pair on the stack, which has to have a branch: : SORT 2DUP < IF SWAP THEN ; then you can build "if-less" MIN, MAX and ABS: : MIN SORT NIP ; : MAX SORT DROP ; : ABS 0 SORT SWAP - ;
- Hizonner 6y agoYou 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.
- shawnz 6y agoWiktionary 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 industry: "access" as a verb
- pavlov 6y ago> “... one common word which does seem to have been invented by the software industry: "access" as a verb” Really? That’s surprising because the French and Spanish equivalent verb (accéder / acceder) is common and has multiple meanings such as “reaching a peak”. I would have imagined this word transferred over in the Norman days.
- chrismorgan 6y agohttps://books.google.com/ngrams/graph?content=access_VERB https://books.google.com/ngrams/graph?content=access_VERB would seem to support the claim.
- pavlov 6y agoWow, interesting. Maybe it’s because “to accede” is also an English verb but acquired a different meaning from the Latin root. Acceding to a computer system doesn’t make sense like it does in French or Spanish, so the noun was turned back into a different verb.
- jiofih 6y agoI believe that sentence should read “or else he would have...” to be grammatically correct.
- mabbo 6y agoIt begs the question: did we search and find the answer of if-then-else, or did we find an answer that was sufficiently likeable and usable- but one of many possibilities? How do we know whether this choice was the global optimum vs a local one? Is if-then-else the electron- a deep truth waiting to be discovered- or the gasoline powered car- an option we explored for decades among others options.
- eat_veggies 6y agoIs pattern matching a generalization of if/then/else, a reframing of it, or something else entirely?
- colejohnson66 6y agoI see it as a cross between a switch and if statement. You’re saying based on what `x` is (a switch), do these things that a switch can’t do (an if).
- alew1 6y agoIf-then-else is pattern matching on a value of type Bool. I think of general pattern matching on algebraic data types as a generalization.
- coldtea 6y ago>How do we know whether this choice was the global optimum vs a local one? By letting anyone free to find a better alternative. Waiting...
- fanf2 6y agoI wondered whether there was a conscious link in the minds of early language designers to Church encoding of booleans. (well, other than McCarthy and Lisp) A Church boolean is either: true = λt.λf.t false = λt.λf.f So instead of writing an expression with keywords like if bool then yep else nope Just use the boolean as a function and apply it to the then and else clauses like bool yep nope So the shape is very similar to modern languages, but with less syntactic scaffolding.
- 6y ago
- michaelcampbell 6y agoI love reading these old manuals; so many of them had hand-written symbols (eg ->) that couldn't be expressed by whatever typesetting system they used at the time.
- troelsSteegin 6y agoThe co-authors of the ENIAC paper are Haskell Curry [0] and Willa Wyatt. Curry is well known. Wyatt (Willa Wyatt Sigmund), along with other women who worked on ENIAC, is remembered here [1] [0] https://en.wikipedia.org/wiki/Haskell_Curry https://en.wikipedia.org/wiki/Haskell_Curry [1] http://athena.union.edu/~hemmendd/Courses/cs80/eniac-women.pdf http://athena.union.edu/~hemmendd/Courses/cs80/eniac-women.p...
- RootKitBeerCat 6y agoEnglish had to be invented
- t0mas88 6y agoI remember something like 25 years ago (when I was 8) that the variant of Basic I used did not have a good if-then-else. Instead it was done a lot using if and goto (with line numbers :-)) Some years later in embedded development I learned that this was actually more similar to the CPU instructions used underneath, conditional jumps.
- wozer 6y agoI 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.
- formerly_proven 6y agoWilling to bet it's either "sonst" or "andernfalls"... I'd suspect the latter, the former is a little bit too informal for mathematicians. Both of these are commonly used for case enumerations in math.
- wozer 6y agoMaybe. On the other hand, "andernfalls" is a bit long as a keyword.
- BlackFingolfin 6y agoAs a research mathematician, I happily use "sonst" in e.g. case distinctions (well, in my undergrad lecture notes; papers are written in English ) and wouldn't use "andernfalls" as it is simply too long :-). Moreover, if they had looked up "andernfalls" in a dictionary, they would have found "otherwise" as translation. For "sonst", the number 1 translation in all dictionaries I have around or found online, is "else". So I firmly believe they used "sonst".
- SilasX 6y agoExcept that you’d then have to make all the operators postfix to match how German puts the verbs at the end of subordinate clauses :-p “wenn a b ==...”
- Tainnor 6y agoah but it's more complicated because only the main verb is at the end of the sentence, so if you need an auxiliary or you have a copular construction like "ist gleich", you need to split the verb phrase... in fact, Germans would say (and do say, e.g. in mathematics) "wenn a gleich b" as a shorthand for "wenn a gleich b ist".
- baking 6y ago"Else" is not archaic. Every kid growing up in the sixties knew that the way to start a fight was to say "Or else!" It was used a lot in cowboy movies before a gunfight.
- gbrown 6y agoI think for these purposes, “else” is different from the “or else” construction. As in: “Read thee the article, else thou shall suffer great ridicule in the comments.”
- ithkuil 6y ago"thee" is the dative (and later accusative) inflected form of "thou", the second person singular pronoun. In your sentence above "Read" is the imperative form of the verb. The subject is elided since it's implicitly second person (singular or plural) (as imperative is used to give orders to people you're talking to) and if it wasn't elided it would have been in nominative case. Middle english had an ending -(e)th to form a plural second person imperative. "Learn the grammar of past and present languages, else you'll attract pedants from the intertubes"
- gbrown 6y agoThis is fantastic
- chrismorgan 6y ago(At least a couple of wrong words there: “thee” should be “thou”, and “shall” should be “shalt”. Also I reckon “thou shalt” reads much better as “shalt thou” in this style, though either is acceptable. Final proposed form: “Read thou the article, else shalt thou suffer great ridicule in the comments.” The overall style of the sentence is still rather off for the era, but it’ll do.)
- gbrown 6y ago“The best way to get an answer in the internet is not to ask a question, but to post something incorrect.” - Thomas Jefferson
- tsimionescu 6y agoI 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: more precisely, in natural language, 'and' usually implies set union, which is more similar to boolean Or. For example, 'women and children' means of course 'if X is a woman OR X is a child'. The other interesting observation was that in natural language we usually describe operations on sets as taking the whole set as an argument, not in terms of what happens with each individual member. For example, 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'. Of course, index based loops are essentially never used in common language, but even the common loop comprehensions that introduce a loop variable are quite far from natural language.
- fouronnes3 6y agoGreat 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.
- gpderetta 6y agoLatin has both in inclusive ('vel') and exclusive ('aut') or.
- cgriswald 6y ago> "or" is almost always exclusive, i.e "do you want to eat pizza or pasta?" does not imply that eating both is an option. English is way too ambiguous for this example and often relies heavily on context. Wanting to eat pizza does not preclude also wanting to eat pasta. If it was exclusive or, and you wanted to eat both pizza and pasta, the honest answer to this question would be "no," but what you should say is "yes."
- chriskanan 6y agoIf 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 constitute an invention since it is just putting a known mathematical formalism into a programming language. It would be possible to implement this in Leibniz' calculus ratiocinator ~300 years ago: https://link.springer.com/chapter/10.1007/978-3-319-93779-3_4 https://link.springer.com/chapter/10.1007/978-3-319-93779-3_...
- kopakabana 6y agoYou should add that to Wikipedia: https://en.m.wikipedia.org/wiki/Conditional_(computer_programming) https://en.m.wikipedia.org/wiki/Conditional_(computer_progra...
- abecedarius 6y agoMcCarthy 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-choice https://codewords.recurse.com/issues/four/the-language-of-ch...) It's easy to think things are obvious in hindsight.
- deleted 6y ago[deleted]
- tempodox 6y agoYour formula `(A --> B) ^ (¬A --> C)` expands to `¬(A & B) & (A | ¬C)`. I would propose that `(A & B) ^ (¬A & C)`, which expands to `(¬A | B) & (A | C)`, comes closer to actual `if` semantics.
- rvba 6y agoIt just sounds like a simplification of "if a then b, in all other cases c"
- LC_ALL 6y agoJust one of those things that no one really questions the existence of. It, like the semicolon, always has been and will be. Good work digging through these historic esoteric languages. Wikipedia states McCarthy of Lisp fame invented it so many of the evangelists here likely know the conclusion here.
- Someone 6y ago“It, like the semicolon, always has been and will be.” Not the best of examples. It hasn’t always been. Early fortran and lisp didn’t have it. Reading https://medium.com/better-programming/a-brief-history-of-the-8efda9dde2b8 https://medium.com/better-programming/a-brief-history-of-the..., it seems Algol and PL/I set the trend to make it popular. Looking at newer languages, I also get the impression it’s on the way out. Rust has them, but python, scala, go and swift try to avoid them (https://python-reference.readthedocs.io/en/latest/docs/operators/semicolon.html https://python-reference.readthedocs.io/en/latest/docs/opera...: “Avoid having multiple statements on a single line. Though the language definition allows one to use a semi-colon to delineate statements, doing so without reason makes one’s code harder to read”, https://golang.org/doc/effective_go.html#semicolons https://golang.org/doc/effective_go.html#semicolons: “Like C, Go's formal grammar uses semicolons to terminate statements, but unlike in C, those semicolons do not appear in the source. Instead the lexer uses a simple rule to insert semicolons automatically as it scans, so the input text is mostly free of them.”, https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID316 https://docs.swift.org/swift-book/LanguageGuide/TheBasics.ht...: “Unlike many other languages, Swift doesn’t require you to write a semicolon (;) after each statement in your code, although you can do so if you wish. However, semicolons are required if you want to write multiple separate statements on a single line”)
- enf 6y agoSemicolons came in with Algol 58 too, which used them in what now seems like a really excessive way.
- np_tedious 6y agoInteresting timing. I just read https://arstechnica.com/?post_type=post&p=1728174 https://arstechnica.com/?post_type=post&p=1728174 due to r/programming https://www.reddit.com/r/programming/comments/kbs11a/a_damn_stupid_thing_to_dothe_origins_of_c https://www.reddit.com/r/programming/comments/kbs11a/a_damn_... yesterday. Apparently Cambridge Programming Language (more or less a failed language that became proto-C) designer Christopher Strachey had some misgivings about this usage of "else".
- deleted 6y ago[deleted]
- enf 6y agoLooks like this article was the source of the Twitter thread https://twitter.com/geoffwozniak/status/1337916048276852737 https://twitter.com/geoffwozniak/status/1337916048276852737 where I revived the discussion of my talk.
- SaladFork 6y agoThis was presented by the author at !!Con West 2019: https://www.youtube.com/watch?v=4A94JsWTXXw
- karmakaze 6y agoThe story of development is interesting, but I doubt that the concept itself needed invention. Even in machine language using nothing but conditional branching the pattern would have appeared enough to be an idiom perhaps without a name: ... b? addr1 ...else stuff jmp addr2 addr1: ...then stuff addr2: ...always stuff What's more interesting is the generalization to any boolean expression, not the naming/placement of the else/always parts.
- Existenceblinks 6y agoI miss that. Chaining jump to continue range of memory of jump is fun. It's all down to comparing hex in 2 registers and jump. JNE, JE, JMP etc.
- proverbialbunny 6y agoYep. I remember naturally writing assembly like that when I was a kid. When I picked up a high level language if statements were not mind blowing, it was already what I had been doing the entire time. What did blow me away was seeing a function for the first time.
- karmakaze 6y agoI learned on 6502 and used jsr/rts (jump-to/return-from subroutine). Recursive functions later in my learning was a mind-blowing moment, then seeing stack frames and call conventions made it less magical.
- Existenceblinks 6y agoJump or not jump Jump or not jump Jump or not jump :out_of_range :the_end
- dahart 6y ago> 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.aspx?headwordId=9622 https://www.shakespeareswords.com/Public/GlossaryHeadword.as... "else used as a conjunction" https://wordtype.org/of/else https://wordtype.org/of/else "Or else!" was common speech before computers, and a common vague cartoon/cowboy/sign threat.
- mlyle 6y agoYup, it grated on me to read that at the beginning. Though: else as a conjunction isn't quite archaic today. But, it is one of those usages that when I encounter it, I begin to suspect that the document I'm reading is rather old.
- SilasX 6y agoEven if it weren’t, that just means we would have called the construct “if-then-otherwise” instead (perhaps abbreviated as othw).
- enf 6y agoI 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.
- armada651 6y agoWouldn'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.
- enf 6y agoAlgol was not prone to abbreviation. Algol 58 used "or if," so if they had wanted "or else," they would have used "or else."
- 6y ago
- efficientsticks 6y agoNice walk through history, interesting to think that at some point if-else was in need of diagrams to describe the concept clearly. When I ran the "if-else" statement of my programming language* by a user-study with my non-technical brother-in-law he said it reminded him of the binary nature of legalise and inherently limiting the nature of what is possible. I agree. My sister also formed the study-group and consistently they both prefer "otherwise" to anything else (pardon the pun). * The language in case anyone wants to take a look: https://github.com/ducklang-community/ducklang https://github.com/ducklang-community/ducklang
- brandmeyer 6y agoChinese also has an interesting sentence structure that doesn't quite fit with European languages. In addition to subject.verb(object) form, there is also a kind of topic-comment form that might be reasonable to use in some assertion-like contexts. ensure(foo), !empty() require(bar), open() Chinese also has a word that can transform some kinds of statements into a question. `ma` is used to form yes-no questions. Imagine if languages with truthy values required you to use an explicit keyword/character in postfix position to take a non-boolean value and use it in boolean context. if predicate: pass if non_predicate ma: pass To be clear, I'm not actually advocating for such constructs. The topic-comment form breaks down as soon as you want a predicate on multiple objects. The automatic truthy values concept is already falling out of favor in preference for explicit predicates like file_handle.is_open(). I don't actually want to program in "Cobol, but Chinese". But it is interesting to explore the space.
- henrikeh 6y agoBulgarian also has a question particle (li or ли). In many cases questions are phrased by simply inserting “li” next to the focus of the question.
- Tyr42 6y agoIf you want to go further, it sometimes feels like the "who what where" pronouns are like sql prepared statements. In English, we have question and answer Q: Where do you want to go for lunch? A: I want to go to that pub for lunch. In Chinese you'd say Q: You want to go to ?? pub for lunch? A: I want to go to that pub for lunch. It even works for numbers, like Q: It is ?? o'clock? A: It is 7 o'clock.
- tejtm 6y agoThe language REBOL used `either [] []` which I now miss regularly. It was great in that by default it pushed to me consider and deal with `else` in every case. There are allot of bugs left when stopping at 'if'.
- still_grokking 6y agoA new REBOL like language is in the making: https://www.red-lang.org/ https://www.red-lang.org/ Definitely worth a look.
- kens 6y agoThat's an interesting and well-researched article. I'd like to put if-then-else in the bigger historical context of "structured programming". In the late 1960s and early 1970s, it was a big debate if programmers should use structured programming, building programs out of blocks with control structures such as iteration and conditionals. (Earlier programs were built from ad hoc control using goto.) This is the context of Dijkstra's famous "Go To Statement Considered Harmful. Although structured programming seems obvious now, there was a lot of resistance. At first, people weren't even sure if structured programming could implement all the required control flows, so someone (Böhm–Jacopini) had to prove the "structured program theorem". Languages needed to be modified to support structured programming, e.g. adding block if-else to Fortran 77. I have to wonder what modern programming debates will seem as obvious in retrospect as the victory of structured programming.
- ilaksh 6y agoMaybe almost every major advance. Personally I think it's just that most people are not good at adapting to new contexts that evolve. And people are not really evaluating things rationally. For example, in the beginning those types of programming languages were completely infeasible to implement due to hardware constraints. So people were not used to them. That created a type of prejudice. Another example. Look at CISC versus RISC. When the context is raw machine code or assembly language, you absolutely want more complex instructions because otherwise programmers are going to a competitor that provides them. But then when you have high-level languages that part of the equation changes and reducing instructions gives other advantages. Neural networks might be another example of an advance that was shunned initially.
- dkural 6y agoFantastic choice of images and linked documents in this article. I learned as much from the linked papers and reports!
- tdeck 6y agoIn 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.
- enf 6y agoThat was a common convention at the time and you can also see it in early BASIC manuals.
- ir193 6y agoI'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.
- marton78 6y agoGerman is generally subject verb object.
- wycy 6y agoSemi-related: Fortran has a where() and elsewhere() statement for applying a mask to part of an array. e.g., where (C/=0) A = B/C elsewhere A = 0.0 end It blew my mind the first time I saw it. I’d never seen else in anything but an if statement before.
- Izkata 6y agoFeels like a good place to drop this for anyone who hasn't encountered it: python's loops have an "else" https://stackoverflow.com/questions/9979970/why-does-python-use-else-after-for-and-while-loops https://stackoverflow.com/questions/9979970/why-does-python-...
- umaar 6y agoRecognised that GitHub username straight away. That author also made "datamaps": https://github.com/ericfischer/datamaps https://github.com/ericfischer/datamaps I remember over 5 years ago, they helped me me visualise 1 billion "Shazam's" (where I was working at the time) onto map tiles. Glad to see they are still supporting developers!
- enf 6y agoThanks. My major public project for map utilities has been Tippecanoe, https://github.com/mapbox/tippecanoe https://github.com/mapbox/tippecanoe
- rzimmerman 6y agoThe use of the word “else” bugged me enough that when I put together syntax for Kal (now defunct, but here’s a link https://github.com/rzimmerman/kal https://github.com/rzimmerman/kal) I added “otherwise” as an alias. It’s interesting to see I’m nowhere near the first to come up with that! Some example syntax: unless name is 'Steve' print 'Impostor!' otherwise print 'Steve' “if” and “else” work, too. But I really did like the “unless” and “but” keywords.
- aj7 6y agoReferring to the three-way “FORTRAN” syntax, you say, “The three-way "if" was more powerful than just checking for a negative, but was probably more confusing,” this is not right. As a 15-year-old at Stuyvesant, in 1966, learning FORTRAN 4, I assure you it was the most natural thing in the world. Especially instructive was the fact that usually two of the target statement numbers would be the same. FORTRAN 4 didn’t have Boolean data types, OR, or AND and += was still in someone’s nightmare. Note also that when Microsoft put IF( , , , ) into Excel, the most widely used computing application in the world, they essentially used this syntax.
- enf 6y agoThanks. It has been cited as confusing in sources like The Elements of Programming Style, but I can appreciate that it may feel natural to some people, and there are certainly cases like strcmp() where a three-way distinction is necessary, and current languages lack a good way to talk about it.
- intrasight 6y agoIt was discovered not invented. All sentient beings will have if-then-else.
- anonytrary 6y agoYou don't need "else". if (x) then: doSomething(); if (!x) then: doOtherThing(); "Else" is a redundant construct, but it's nice to have for sure. I would prefer not writing the above code.
- o_nate 6y agoThis doesn't work like "else" if doSomething() can change the value of x.
- anonytrary 6y agoThat's true! You could cache x as a constant beforehand, but again super ugly.
- BurningFrog 6y agoOne of my first jobs was using the IBM mainframe RPG III language in 1985. About half a year in, and new language version introduced IF/ELSE statements. I was glad to finally get a semblance of modern programming, but the old RPG veterans advised against using it, since the new fancy features often didn't work so well, and anyway you can write anything you want without it. After 14 months, my contract wasn't extended. Maybe the complaint that I could be seen sleeping at my desk sometimes were a factor. You young kids don't know how good you have it...
- apricot 6y agoFun fact: English isn't my native language and I learned programming before becoming fluent in English. I believed for a long time that 'else' was just a shorter alternative for 'otherwise'. I used to say things like "I'll have apple juice if you've got some, else I'll have orange juice."
- fernly 6y agoThat's valid, if slightly odd, English. More commonly it would be "or else I'll have the OJ".
- dragonwriter 6y ago> I believed for a long time that 'else' was just a shorter alternative for 'otherwise'. It has other uses, but it is that (that is, “or else” is exactly that, and, among other uses, “else” by itself is an accepted short form of “or else”.)
- howLongHowLong 6y agoThis is a totally correct usage, it just makes you sound like a romantic poet or a 19th century orator.
- dhosek 6y agoI had to check whether my memories of my first programming language (AppleSoft BASIC) were correct and they were: that language did not offer an ELSE statement. There were just IF expr THEN cmd and IF expr GOTO line. I don't remember being shocked or overly impressed by the existence of else when I first encountered it in UCSD Pascal, but I do have vague memories of having to write code in AppleSoft BASIC that either was structured with IF this... IF not this or perhaps IF this GOTO 40, do what would be in the else then goto the line after the code starting at 40, then the code for the if statement.
- mjd 6y agoI can remember my mom telling me, sometime in the late 70s or very early 80s, that she thought the new version of Fortran was an improvement because it had `else`.
- dwd 6y agoThe logic of deciding on a course of action based on a single determinate decision was not a new concept. I would think Soren Kierkegaard deserves a hat-tip to his existential work: Either/Or.
- wwwwewwww 6y agoI would love to read something similar about a "for" loop. "if/else" always sounded natural to me, but a "for" to mean a loop never did.
- TeMPOraL 6y agoI bet it's from maths. "For k in Z, ...". But in programming, imperative is more useful than declarative, so we turned this into "For k from 0 to ...", as it translates directly to telling the computer what to do - and this is the form most programmers ended up being exposed to.
- enf 6y agoFor is also from Algol, replacing "do" from Fortran. I agree it would be interesting to know why the word was chosen, but I think it comes from the mathematical "for all x in Y, x > 5" or whatever other assertion is being made.
- ck2 6y agoThat was a fun read. Was that original research? Great job if so.