If-then-else had to be invented
201–210 of 255 posts
Re: If-then-else had to be invented
#202Earlier quoted context omitted.
> The article was fascinating, especially the historical examples from different programming languages, and I buy the plausibility of a German speaker using “else” this way... I work with German speakers and they do it all the time. From the small amount of German I know, it feels like there might be some parallel with “als”. I‘m a native German. It was certainly not „als“ as this translates to either „than“ as in „m…
I shouldn't speculate I guess. :) Als sounds like a cognate to else, but maybe it's not related. Looking up etymology for "else", I see it comes from old High German's "elles". https://en.wiktionary.org/wiki/else#Etymology > „falls“ for „if“ This one is interesting in the same way that it might lead me to the wrong conclusion. Is 'falls' related to 'falsch' at all? The English 'falls' is used quite differently, thoug…
Nope, according to Kluge's German etymological dictionary, "falls" is from a Germanic root most literally meaning falling (down) (just like English "fall"), while "falsch" is borrowed from Latin falsus, which in turn comes from the Latin verb fallere, to deceive (like "fallacy"). (Wiktionary also traces the two of them to different Indo-European roots.)
There's an interesting side note that German Fall (the origin of "falls") means "case" (both in the grammatical sense, related to noun forms, and in the senses of "a logical possibility" or "a fact": Wittgenstein's Tractatus starts out with "Die Welt ist alles, was der Fall ist" -- "The world is everything that is the case"), and in fact the English word "case" comes from Latin "casus" (originally literally 'fall' as in the act of falling down), and the German use of Fall in the senses having to do with logic and grammar was a conscious loan translation which Kluge says was devised by Christoph Helwig in the 17th century (intending to translate Latin "casus").
Kluge says that the grammatical sense of Latin "casus" for noun cases was itself a loan translation in Latin from the Greek πτῶσις (literally, 'fall(ing)') which was used by "Stoics" to refer to noun forms by analogy with the possible ways that dice could "fall" when you rolled them. (I don't know why the Stoics would have been the first to write about grammar this way, but maybe...) Apparently the word ptosis is now mainly used to refer to drooping eyelids (!).
Anyway, the idea of different ways that dice (or nouns or fate or situations) could "fall" are different "cases" is a commonality among many languages but the relationship is apparently conscious, on the part of educated people like Christoph Helwig who were trying to find ways of translating technical terms.
That also means that if the German programmers in the mid-20th century were trying to translate "falls ... dann ... sonst" the best English translation would plausibly have been "case ... then ... else" rather than "if ... then ... else". :-)
(English "else" is usually used to translate "sonst" in "was sonst"/"sonst (et)was", but "otherwise" is usually used to translate "sonst" as a conjunction. So you could also imagine that the "else" was inspired either by the dialectal form some other people in this thread are mentioning, or by someone who just didn't realize that "otherwise" would be more usual in this context for Americans.)
Re: If-then-else had to be invented
#203Fun 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."
Re: If-then-else had to be invented
#204Fun 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."
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”.)
Re: If-then-else had to be invented
#205Earlier quoted context omitted.
Except 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 ==...”
ah 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".
Re: If-then-else had to be invented
#206Re: If-then-else had to be invented
#207You 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.
Re: If-then-else had to be invented
#208It 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.
I lean toward "if a b c" being a true primitive, due to it being one of the special forms in Lisp. This is necessary to avoid evaluating the arguments in the road-not-taken, without fexprs, and I daresay that would be a distraction at the moment. It's also embodied in actual machine words. The actual verbiage of "if a then b else c" is clearly less important, C elides the "then" after all. I'm presuming you mean the…
MacCarthy writes, in History of Lisp:
I invented conditional expressions in connection with a set of chess legal move routines I wrotein FORTRAN for the IBM704 at M.I.T. during1957-58. This program did not use list processing. The IF statement provided in FORTRAN1 and FORTRAN2 was very awkward to use, and it was natural to invent a function XIF(M, N1, N2) whose value was N1 or N2 according to whether the expression M was zero or not.
Yet, no such thing was added to Lisp, initially. The 1960 Lisp 1 Programmer's Manual only lists COND.
Re: If-then-else had to be invented
#209I 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:…
I like the use of language in perl and wish it was more prevalent in other languages. For example instead of saying "if not " you can also say "unless " which is more natural imo.
unless a
a = 4
end
return x unless y
return z