5 ms·
"3. Equals is a lie: = ≠ =" This is why languages like Pascal (and it's descendents) use := as assignment. There are contradictory opinions about sytnax among
by chestnut-tree 11y ago
"3. Equals is a lie: = ≠ ="
This is why languages like Pascal (and it's descendents) use := as assignment.
There are contradictory opinions about sytnax among programmers. Many programmers don't like the example assignment syntax above, but then many programmers also say that syntax is a relatively minor aspect of learning a language (even though the syntax of a language shapes the way you think about solving problems).
And many programmers do avoid certain languages precisely because they dislike the sytnax.
Nikalus Wirth, who created Pascal, Modula-2 and Oberon, had this to say about using the equal sign for assignment:
"A notorious example for a bad idea was the choice of the equal sign to denote assignment. It goes back to Fortran in 1957[a] 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."
- seiji 11y agoSingle assignment languages are a big help here too. http://erlang.org/pipermail/erlang-questions/2001-November/004090.html http://erlang.org/pipermail/erlang-questions/2001-November/0...
- tikhonj 11y agoAs contradictory as it sounds, syntax is both important and unimportant at the same time. It's important because it affects how code is read and how code is written. Programmers naturally lean towards constructs with light syntax and away from constructs with heavy syntax: just think about defining maps in Python or JavaScript (with nice literals) vs in Java, or think about higher-order functions in Haskell (with currying and tiny lambdas) vs JavaScript vs Java. And, as the article pointed out, the syntax can affect how somebody learns a programming language. On the other hand, syntax is unimportant because we learn to see beyond syntax, to the concepts underneath. Syntax is ultimately just notation and notation is not the most important thing. Semantics are important! There are much deeper differences between languages than mere syntax. At this point, I don't even think of code in terms of concrete syntax most of the time, although this might be exacerbated by my background studying programming language design and theory. Personally, I think different people tend to overemphasize one side of this or the other, with more people over valuing syntax than not. In my perfect world the solution to confusing syntax would be to teach people to disassociate syntax and semantics early on, but that's a tall order. Perhaps people could read Godel Esher Bach, which engenders the right mindset :).
- YeGoblynQueenne 11y agoThe funny thing is that there is a mathematical symbol for assignment, the left-arrow, "<-". At least it's used widely in algorithmic notation to show assignment- and also in R.
- noonespecial 11y agoI had a wise teacher early on who without fail used "becomes the same as", "is assigned to", and "points at" when reading code out loud. "Is equal to / equals" was only for comparisons. This has helped me to this day.
- ap22213 11y agoCould part of the problem be that programming languages hijacked ASCII characters which partially hijacked typewriter functionality? Pascal was always my least favorite language, because it never felt practical. For instance, its assignment requires two shifted keystrokes. Whereas the equal symbol requires one non-shifted keystroke. In my ideal world, ISO would just standardize programming symbols. Then, languages could build around those common symbols, and then better input devices could be designed. It amazes me that for as much money we spend on software (How many millions of programmers are there in the world?), we're still using a modified typewriter as our primary input device. Look at all the nicely designed specialized input devices we have for video games; surely we can come up with something better for programming.