Hacker News new | past | comments | ask | show | jobs | submit login
[dupe] If-then-else had to be invented (github.com/e-n-f)
34 points by s1291 81 days ago | hide | past | favorite | 18 comments




I just watched the associated video and had a "holy shit" moment at the mention of "else" as archaic English—I've been so immersed in programming for so long that I'd forgotten how uncommon and old-sounding else is, if I try to use it in common English outside a few set phrases, mostly in question form (e.g. "what else?", "how else?"). "Otherwise" and a bunch of other words suggest themselves as more obvious for this case, looking at it from that perspective.

[EDIT]

http://www.websters1913.com/words/Else

The closest to how it appears in programming is "adv. & conj." sense 2, which is pretty clearly archaic-sounding. The example given is: "For thou desirest not sacrifice; else would I give it." which seems pretty representative to me. But more directly relevant to its use in programming languages, perhaps, it gets the manicule-denoted aside (not sure how the manicure will come across on HN):

After ‘or', else is sometimes used expletively, as simply noting an alternative. "Will you give thanks, . . . or else shall I?" Shak.

We use it "expletively"! How wonderful. Though we drop the "or", if we take it that way.

Sense 1 is adjacent, but less closely-related to the programming use (as is clear in the examples): "1. Besides; except that mentioned; in addition; as, nowhere else; no one else."

"a. & pron" definition remains modern-sounding, and is what I mentioned above the edit as the ways in which it commonly occurs in modern language.

Overall, I'd say the "it was an awkward translation from German" hypothesis is pretty reasonable.


It's common with or, like You'll need to buy soap or else we won't be able to wash.


It's noted, for that case, as "expletive" because it's unnecessary. "Or we won't..." versus "or else we won't...".

[EDIT] though you're correct that that usage is not uncommon, to be clear.


If you go back in time did you know? Yes, the space between words had to be invented. Let's thank Irish monks.


> Why did they call it "else?" They don't say.

> What they do say is that this document was originally written in German and hastily translated into English. I think a carefully-chosen German word was probably translated as an archaic English word and then never revisited.

Of course that's a bit of a guessing game, but I think "sonst" could be a good candidate. It means the same as otherwise, is short (short form of "ansonsten") and I can see a hasty translation turning it into else. An "or else" might have made more sense, however that's two separate words.


Thank god it’s not “otherwise” or “alternatively”.


Haskell has “otherwise” as a built in constant that equals true. It reads better in some cases.

    f n | odd n     = 3 * n + 1
        | otherwise = n \\ 2


MATLAB has 'otherwise' in switch statements:

  switch switch_expression
    case case_expression
      statements
    case case_expression
      statements
     ...
    otherwise
      statements
  end
https://www.mathworks.com/help/matlab/ref/switch.html


I really like "otherwise", it might be easier for non-programmers to understand for one.


We'd have an "otherwise" key on our keyboards.


I have recently come across "unless" which I would find very difficult to love, mostly because it is a word we very often place after a statement. As a COBOL programmer we made it up as a joke, always coming at the end of a long and complex piece of code.


Nice. I know a bit of tech trivia (and used FORTRAN, Ada, cobol, and others), but this was new to me!


Too bad in most languages it is hardcoded into the language as opposed to a user defined construct.


You mean like a macro? You would still need some underlying mechanism to conditionally execute code.


Hehe, this reminds me of a story Ray said. It was along the lines that an old programmer at Microsoft liked Fortran henceforth all his programs written in Assembler were full of macros that emulated Fortran. When the old programmer retired and one of his programs had to be maintained the new guy, unable to read that Assembler full of macros, simply took the executable and disassembled directly and used that as source.


In computing this is the basis for AI.


I like this recent history, but it's worth remembering that we invented this sort of statement millennia ago: https://en.wikipedia.org/wiki/Code_of_Ur-Nammu




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: