A r t i c l e s
Navigation

Note: This site is
a bit older, personal views
may have changed.

M a i n P a g e

D i r e c t o r y

Assignment Operator Religous Wars


I recall in math class (and I was in advanced math class) when my teacher was writing things on the chalk/felt board.

She says and wrote something like:

  let x = 6
  x + y = ??
I don't see any ":=" assignmeny in there.. I see LET X = 6

This is equivalent to initializing x to 6. But how can x magically be initialized to 6 with an equal sign, if we are not doing comparison? We are telling x to be equal to 6, we are not comparing it. This is an assignment. When we tell x to equal six, we are assigning the number 6 to variable x.

When I first started modern pascal programming, I read of some religious wars going on about how it was ESSENTIAL that the assignment operator be := because it was more mathematical. In school math class, I don't recall seeing my teacher ever using :=, but I always recall her saying and writing something like "let x equal 6" or "x = 6 so..".

Well, well then. Is it really true that this := operator is superior as Wirth claims? Are the Pascal fanboys really correct?

It's kind of like arguing that in Spanish it is proper to use an upside down question mark at the start of every question. Why in English is there no upside down question mark at the front of each question?

I thought about the = and := war some more. When I started looking into my old pencil math scrap coil books... I noticed that I assigned x values using the equal operator, and I compared x to other statements by using the equal operator. And so did my math teacher.

I was always taught when we first start out an equation, we make x = 6 or fill in some values. This is assignment. Then we compare the values. Then we might test some more values and assign some new numbers. There was never really any true distinction between assignments and comparisons.

The only way to make it clear that an assignment was happening in math, was to use words like ASSIGN VALUE 6 TO Y which is never used because it is too verbose. The only way to make it clear that comparison was happening was to use words like IF THEN. But these aren't used as much in math because apparently mathematicians are too lazy to write these words out.

If languages forced us to type LET each time or ASSIGN X TO, that might get annoying. Some languages have the LET keyword. I am not sure why Niklaus Wirth didn't choose something like this LET keyword since he chose big words like BEGIN and PROCEDURE and FUNCTION.. if taking it that far, why not take it one step further and replace the := operator with the keyword ASSIGN or use LET ahead of the assignment? It would after all make it clearer, wouldn't it? The answer is, terseness is in fact a big role in programming languages... even Pascal. There will be many Pascal progammers out there who religiously defend verbosity, but the reality is := and + and - signs are terse shortforms.

The word ASSIGN is more clear than :=.. and even math folks still use = when initializing a value at the top of a problem. Why don't they use := or ASSIGN? Some people claim that math doesn't have assignments since it not a state, it's more like a proof.

What is confusing also is that initialized modern pascal variables are notated as:

var
  global: integer = 6;
Hey now, Mr. pascal fanboys.. why all of a sudden are we using COMPARISON logic in an initialization? Shouldn't that be:
var
  global: integer := 6;
It isn't as if we are COMPARING whether the global variable equals 6 or not. We are initially assigning the global variable to 6. Where is comparison? There is no comparison here.

Therefore, I proclaim that the Pascal ":=" religion is flawed or confusing. The fanboys that protect the := are contradicting themselves when they use = to assign global variables with an initial value. Some claim you aren't assigning an initial value, you're just forcing it to be equal... but it's still not a comparison.

Furthermore, in my math scrap books, I've done this before:

x = 6
y = 7

x + y = ??
6 + y = ??
6 + 7 = 13

x = 8
y = 2

x + y = ??
8 + y = ??
8 + 2 = 10
This is like a program with assignment because at first x was 6, then further down 6 was 8... so it wasn't full fledged comparison going on but some assignment.. i.e. the math had some state, even though math is not supposed to. Are some people that practice math diving into programming with state, without knowing it?

I let x equal some number, and I let y equal some number, and then I fill in some more values for x and y and try out some different experiments. NO WHERE DO I USE THE PASCAL ASSIGNMENT OPERATOR :=

I'm not COMPARING whether or not y equals 7, I am demanding that y be assigned 7, since I am able to command my y to do that. I own y, y is my slave. I have every ability to tell what y can be.

In math class, I also remember my teacher saying things like "if y = 6 then we can do this..". But how did y first become 6? Who assigned y to be 6? Somehow, "y" had to be assigned. No where in math class did we learn how to assign y to 6.. we just did so automatically with the equal sign, because in math class, WE ASSUMED THAT IF y EQUALS 6 THEN IT ALSO MEAN THAT IT HAS BEEN ASSIGNED TO 6.

Therefore, whether or not one uses := or = to assign a number, is a religous war - and math has possibly taught us some bad habits. There was never a distinction between what was truly being "compared" and what was truly being "assigned" in many mathematical statements, nor any indication that something was being initialized or set to some value. When y was set to x, we never said that y was set or assigned to 5.. we just said "y = 5" or "let y be 5" or "assume that y is 5", or "y is equal to 5 so".

To me, this whole assignment versus equal comparison religious bull shit all seems to be stemmed from a simple problem. The problem is, some one made the mistake of thinking that in math, one does not assign things values. This is not true. Because of this lie that someone spread, then it became a flamewar and even the inventors of the Cee language started believing the bullshit.. stating that Cee doesn't use the right assignment operator because = is shorter and easier to type than ":=".

In math, we plenty of times assign x values.. we initialize x with values. Initialization is a form of assignment.. you can argue all day long, but initialization is a form of assignment. And in math, sometimes we change the value of x and y further down in our scrap paper because we want to experiment with some new values. IS THIS NOT ASSIGNMENT? AND DO WE NOT USE THE EQUAL SIGN?

So to me, as soon as I hear someone arguing about := vs = then I immediately blame math for not coming up with an assignment operator, which would have officially set the symbol for us. If math had come up with ":=" or "->" or "<-" then that would have been the symbol for programming languages too.

What's more important than this religious bull shit, is compiler checking of "if logic" checks in programming... the compiler should not let one do this

  if x assign to y then do
it should only allow you to do this:
  if x equal to y then do
What is worth arguing about is how the Cee language let's you do that above assignment in the if logic. This should not be permitted.

The compiler can still prevent assignments from happening in the if logic, if we use the == sign for comparison and the = sign for assignment.

If Pascal and its successors were truly concerned about verbose readability, then they would be designed like this:

VAR
  X: INTEGER;
BEGIN
  X ASSIGN VALUE 5;
  IF X = 5 THEN
  BEGIN
    WriteLn('X equals five');
  END;
END.
Using the operator := is just as terse as Cee using { and } instead of BEGIN and END. Instead, Pascal and its successors are worried about terseness.. so they choose the := operator just like mathematical folks use funny terse symbols.

And if mathematical folks were truly concerned about readability, then mathematical folks would not write things like this:

x = 5
y = 6
x + y = ??
They would instead write this:
LET x be SET TO 5
LET Y y be SET TO 6
x + y = ??
Instead, mathematical people decide that terseness is more important.. so they use the equal sign for initialization assignments in equations, and they use the equal sign for comparisons too - making mathematical people even sloppier than Cee programmers. At least Cee programmers differentiate between equal signs and comparison signs, and at least Pascal programmers differentiate between equal signs and comparison signs. It is the mathematical folks who are on crack, not the programmers.

p.s. I prefer upside down question marks at the beginning of questions because it lets one find questions in prose much easier if scanning text from start to end rather than from end to start.. I've never learned spanish or never spoke spanish, I have just briefly read about the language.

About
This site is about programming and other things.
_ _ _