Live data from Hacker News

If-then-else had to be invented

github.com

21–30 of 255 posts

Re: If-then-else had to be invented

#22
post #13

Earlier quoted context omitted.

Having 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 */ {…

What 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

True!

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.

Re: If-then-else had to be invented

#24
The 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 [1] http://athena.union.edu/~hemmendd/Courses/cs80/eniac-women.p...

Re: If-then-else had to be invented

#25
post #9

If/else is just as made up as for loops - it’s all if/goto underneath.

Unless you compile your program with movfuscator: https://github.com/xoreaxeaxeax/movfuscator Or you decide to execute code on The 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 likel…

> 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

Re: If-then-else had to be invented

#26
post #20
post #8

Earlier quoted context omitted.

Wiktionary 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…

> “... 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.

https://books.google.com/ngrams/graph?content=access_VERB would seem to support the claim.

Re: If-then-else had to be invented

#27
post #6

You 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.

In colloquial english we usually put an "or" in front of else. It really breaks down when you put it in boolean form because the "or" implies other actions when true rather than actions if false. Removing the "or" completely is unambiguous but is antiquated English.

Examples: "Go to college or else work for your uncle"

Turn this into boolean form: "If you go to college then or else you will work for your uncle"

But the "or" makes the meaning ambiguous: "If it rains then I will work inside or else I will work outside."

It is not clear if this means you will work outside if and only if it is not raining? Maybe working outside is another option if it rains.

Otherwise is far more clear. "If it rains then I will work inside otherwise I will work outside."

Removing the "or" completely makes the statements unambiguous archaic English: "If you go to college then else you will work for your uncle" "If it rains then I will work inside else I will work outside."

FWIW - I am very glad they chose else over otherwise...

Re: If-then-else had to be invented

#30
post #6

You 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.

It does not even register as “archaic” to me. Methinks it's rather ordinary.

Indeed it would behoof us not to assay to declare words archaic ere their time
Post reply on HN