Why did programming languages start using = for assignment?

In most early algorithms books, <- referred to assignment and = referred to comparison. But nowadays the only languages that don't use = for assignment are Pascal (:=) and toy languages like COOL. What caused modern programming languages to change = into meaning assignment instead of its mathematical meaning of equality?

• Don't get me started on ===... – Deer Hunter Mar 17 '15 at 7:10
• remains common in algorithms work; it's one of three common notations for assignment when writing an algorithm (the others being := and =). Just because programmers all use = doesn't mean mathematicians all dropped . – cpast Mar 17 '15 at 16:10
• @DeerHunter === is fine. – Darth Egregious Sep 21 '15 at 19:54
• I had a middle school girl howl: "How can x equal x plus one?" in an intro I taught. The is the fundamental weirdness of computers: variables do not exist in nature, they are unlike any other thing in the universe. – user251748 Sep 27 '17 at 18:26
• User251748: My wallet is a real world variable, containing a multi set of coins, bank notes, and occasional bits of paper. – gnasher729 Oct 11 at 16:28

According to Wikipedia, the use of equals for assignment dates back to Heinz Rutishauser's language Superplan, designed from 1949 to 1951, and was particularly popularized by Fortran:

A notorious example for a bad idea was the choice of the equal sign to denote assignment. It goes back to Fortran in 1957, and has blindly been copied by armies of language designers. Why is it a bad idea? Because it overthrows a century old tradition to let “=” denote a comparison for equality, a predicate which is either true or false. But Fortran made it to mean assignment, the enforcing of equality. In this case, the operands are on unequal footing: The left operand (a variable) is to be made equal to the right operand (an expression). x = y does not mean the same thing as y = x.

—Niklaus Wirth, Good Ideas, Through the Looking Glass

Konrad Zuse also used the equals sign for Plankalkul, which inspired to Rutishauser's Superplan, although a compiler was never devised for it. Why did he choose the equals sign? I guess you'd have to ask him.

• Well, there certainly were worse ideas. After all, mathematics texts use = both as a predicate and to define variables, e.g. in “Let x = 4. Then √(x - y) is zero if y = 4”. This works because maths notation should be understood declaratively rather than imperatively. Functional programming languages (e.g. the ML family) default to non-mutable variables and can therefore continue to use = in its dual role without any problems. Or more precisely, = is both an operator and part of the let syntax. – amon Mar 17 '15 at 1:33
• @amon: I disagree about the dual meaning in mathematics. "Let 4 = x" is just as valid as "Let x = 4". – COME FROM Mar 17 '15 at 7:59
• @COMEFROM "Let 4 = x" is about as unnatural as the INTERCAL statement from which you take your user name. When "x" has never been mentioned before, "Let x = {something}" or "Let x be a {widget}" introduces a variable in addition to specifying its value and this puts the variable first by convention. That's precisely because, at least in terms of intuition, this is a different thing from just stating "the value equals ...". – user7043 Mar 17 '15 at 9:38
• @delnan "Let x = 4" is just shorthand for "Let x ∈ ℤ and x = 4". The context introduces the new variable and = is then just a predicate, same as it is anywhere else it's used. Note that depending on the context, "Let x = 4" could've also meant "Let x ∈ ℝ and x = 4". – Doval Mar 17 '15 at 11:45
• @RobertHarvey We're talking about mathematical writing, not C programming. COME FROM: I concede that it's not as clear cut as I put it before, but since mathematical prose is based on conventions and there is no specification that can be lawyer'd to permit "let 4 = x", no, said statement is not just as valid as "let x = 4". At the very least, it confuses readers and hence fails the primary purpose of the prose. – user7043 Mar 17 '15 at 18:08

But when I did math at school "let x = 123 "

was common phrasing. Early versions of Basic insisted on the "let" keyword before the equal. So its basically boils done to "let" is understood.

A key driver not usually considered but very important at the time it what did you actually type on.

There were two feasible input devices,

• The "teletype" whereby you could use a standard teletype machine to punch little holes in a paper ribbon which could then be read by the computer. This was not so bad as it supported the standard aplphabet in upper and lower case plus most of the characters on the top row of your keyboard.
• Punched cards -- there were lots of punch card machines hanging around as the use of sorters, tabulators and printers was common in large corporations. These supported a ery limited character set Upper case only alphabet and a limited number of "special" characters.

Teletypes tended to be used in academic and military shops, card punches in more commercial shops. Hence academic languages like Pascal supported lower case identifiers and "sensible" notations like ":=" for assignment. Languages aimed at a more commercial audience assumed that punched cards would be the main form of input hence the Upper case only languages like FORTRAN and COBOL with there limited support for ":;><" characters which were unavailable on a standard keypunch.

Incidentally there was no ambiguity about "=" being used for assignment in early FORTRAN as comparison was done using the ".LT.", ".LE.", ".EQ.", ".GE." and ".GT." syntax.

• I find let x = 123 more analogous to assert(x == 123) than any kind of assignment, though. – AKHolland Mar 17 '15 at 18:18
• P.S. If you are getting pedantic then the COBOL "MOVE" syntax is the most accurate description of what the computer is actually doing. Although "COPY" would be even more accurate. – James Anderson Mar 19 '15 at 6:17
• @AKHolland for large values of 123. – user251748 Sep 27 '17 at 18:24
• Since C++ invented move constructors, COBOLs “MOVE” sounds a lot weirder. – gnasher729 Oct 11 at 16:30
• I always thought LET should have remained mandatory in BASIC, since it would make assignment stand apart from equality testing. Sort of COBOL-ish shorthand. Problem is, that would take up another another token in the source, another precious byte in the teeeeny tiny PC's of the time. So they dropped it. – Chuck Adams Oct 13 at 1:39