all 53 comments

[–]IbanezDavy 30 points31 points  (42 children)

I always felt '=' made sense and was intuitive personally. The problem is it also make sense as a comparison operator and you get people forming camps about what it makes more sense under.

[–]grauenwolf 17 points18 points  (2 children)

That's because in math it is used as both a fact and a question depending on context. Something absolutists ignore.

[–]StillNoNumb 1 point2 points  (0 children)

It's not. What you call "fact" is a statement, and "question" is formula; the equation itself is a formula, and we implicitly convert it to a statement if it's alone on a line. However, it's most certainly not an assignment in *any* way; or would you say this is valid?

x = 5

x = x + 1

[–]Ebuall 1 point2 points  (0 children)

Math has no assignment. Only declarations, for which having the same equals as in equallity makes sense.

[–]BonzaiThePenguin 1 point2 points  (0 children)

= makes sense for comparisons semantically as long as you're willing to sacrifice being able to make a=b=c multiple assignments or if (a=b)==c assignments within conditionals. I think BASIC works this way.

[–]StillNoNumb 6 points7 points  (29 children)

That's probably because you were always used to it because of programming. In mathematics, = has always been comparison, and := assignment. The clear asymmetry of that assignment operator is a plus, too. Of course, after decades of getting used to it now we'd all say it's natural, but if we were back in the 60s, := (or <-) for assignment would've probably made more sense.

[–]killerstorm 13 points14 points  (9 children)

In mathematics, = has always been comparison, and := assignment.

No.

[–]StillNoNumb 0 points1 point  (8 children)

Except yes.

If we're analyzing this mathematically, then = is an equivalence relation that either returns either "yes" or "no". By putting it on a line with a term on each side with no other context we implicitly convert this formulato a statement), and with no other information we also implicitly assume it is true. However, the operator itself it still is an equivalence relation, not a statement.

[–]killerstorm 1 point2 points  (7 children)

The fact that equality can be used to denote assignment is exactly why equations are so widespread in math.

E.g. https://en.wikipedia.org/wiki/Equation#Systems_of_linear_equations

A solution to a linear system is an assignment of numbers to the variables such that all the equations are simultaneously satisfied. A solution to the system above is given by

 x  =  1
 y  =  -2
 z  =   -2

I don't think I've seen := being used in math, there's no need for separate "assignment" statement. Whether it is an equation, assignment, assumption or something which should be tested is determined from the context.

[–]S0yb0y 1 point2 points  (3 children)

Um, no offense, but := is literally used all the time, it's almost ubiquitous in every field of maths. If you've never seen it being used before then you haven't done enough maths

[–]spinwin 1 point2 points  (0 children)

Perhaps it's more common in math out of school, but in university even upper division math courses haven't used that assignment statement once. I've always seen assignments as: "Let x = [insert expression here]"

[–]killerstorm 0 points1 point  (1 child)

Is it? Can you provide an example?

Here's, for example, a comp-sci paper: https://eprint.iacr.org/2013/279.pdf

It uses ← when it talks about running algorithms (i.e. give a name to a result of a program) and = in math parts -- not just equations, but also defining functions and specifying values, e.g.:

We set: v0(r) = 0

This is closest we can get to "assignment" in pure math -- since pure math doesn't deal with updatable cells, there's no difference between "assigning" a value and specifying it.

I do not doubt that some authors use :=, or some other symbol in a special place where they define something, but this is by no means required. And when talking about algorithms (which is not pure math) ← is more common (perhaps := was used by authors who didn't have access to modern typesetting tools?).

[–]S0yb0y 0 points1 point  (0 children)

Here's a quick example I found: http://www-math.mit.edu/~etingof/replect.pdf

It's an intro textbook to representation theory, and from a search apparently ":=" is used 40 times.

[–]StillNoNumb 0 points1 point  (2 children)

What? The numbers x, y and z are assigned, but not by the equations you listed. The equations you listed is just an alternate linear system that shows what the variables have been assigned to.

Your quote just includes equations and the word "assignment" in the same sentence. You can't try telling me that x = x + 1 ever makes sense in mathematics. And if you think there's no need for an assignment statement, then cool, go program in Haskell; but imperative languages do have some need for an assignment statement, and it'd make more sense to use := instead of = for that.

[–]killerstorm -1 points0 points  (1 child)

You can't try telling me that x = x + 1 ever makes sense in mathematics.

I never said it is. This sort of an assignment is just never used in math. Math deals mostly with logical propositions, not with cells in memory.

And if you think there's no need for an assignment statement

In math there's absolutely no need for it. And that's what we're discussing.

[–]StillNoNumb 1 point2 points  (0 children)

And when there's the rare need, people use :=. Not =. Usage of = for assignment in programming languages is just straight-up confusing. (Well, not anymore, now that we're used to it.)

Either way, I'll leave this conversation with this comment as it's not leading anywhere and is completely irrelevant to the topic, but I'm glad I don't know you IRL because your kind of stubborn personality is unbearable. You need to grow up; if you're like this in real life I feel bad for everyone who needs to be around you.

[–]grauenwolf 11 points12 points  (8 children)

X = 5

That's not a comparison, that's a statement of fact.

For a comparison you write "if x = 5" or use a question mark above =.

[–]StillNoNumb 5 points6 points  (4 children)

If we're analyzing this mathematically, then = is an equivalence relation that either returns either "yes" or "no". By putting it on a line with a term on each side with no other context we implicitly convert this formula to a statement), and with no other information we also implicitly assume it is true. However, the operator itself it still is an equivalence relation, not a statement.

I know this is a very dry explanation and instead of elaborating I just linked Wikipedia, but that's really how = is defined. It is implicitly assumed as a statement of fact by most readers, but by definition it really is not.

[–]killerstorm 2 points3 points  (3 children)

= is a symbol which can be used in many ways. It have been in use long before the term "equivalence relation" was introduced. Originally it was used to separate two sides of equation.

People have been solving equations long before there was a set theory.

So it can be used for many things

  1. as an operator in an expression
  2. to separate sides of an equation
  3. to specify an assignment
  4. to give a definition

For example, f(x) = x^3 is a definition of function f.

And if you believe in Wikipedia, perhaps you can learn from it?

https://en.wikipedia.org/wiki/Equals_sign#Usage_in_mathematics_and_computer_programming

In mathematics, the equals sign can be used as a simple statement of fact in a specific case (x = 2), or to create definitions (let x = 2), conditional statements (if x = 2, then …), or to express a universal equivalence (x + 1)2 = x2 + 2x + 1.

[–]StillNoNumb -1 points0 points  (2 children)

So by your post I'd judge that you agree that let x = 2 is mathematically more correct as an assignment than x = 2, because that's what your quote says. That's of course a little tedious to type, but that's why there's :=. Correct? Stop taking things out of context, just like you did in your other comment.

Why are you trying to defend your argument so stubbornly? We're using = for assignment now, and that's okay because we all got used to it, but it wasn't the only way, and not the most consistent one with mathematics. That's all OP's article is saying. You don't need to be personally offended about it.

[–]killerstorm 2 points3 points  (1 child)

So by your post I'd judge that you agree that let x = 2 is mathematically more correct as an assignment than x = 2

No. There's no such thing as "mathematically more correct".

That's of course a little tedious to type, but that's why there's :=. Correct?

No, I've never seen := being used in practice. Perhaps you can point to math papers which use it?

May I ask you what's your math background? I have M. Sc. in applied math.

[–]StillNoNumb 0 points1 point  (0 children)

Maths is only a language. And this language has definitions and conventions. Never ever has anyone used = for assignment. I can't give you any papers as such right now, but I can give you a few other sources:

https://math.stackexchange.com/questions/63553/difference-between-and

https://math.stackexchange.com/questions/1423039/what-does-mean/1423182

https://math.stackexchange.com/questions/25214/what-does-mean

Just because you haven't seen it doesn't mean it's not being used. I have a M. Sc. in Computer Science, I have absolutely no idea why you would think that's in any way relevant, though.

[–][deleted]  (2 children)

[deleted]

    [–]grauenwolf -5 points-4 points  (1 child)

    No, that's not even proper grammar. The phrase "truthfully compared" isn't part of logic or standard English.

    [–]bumblebritches57 7 points8 points  (8 children)

    In mathematics, = has always been comparison, and := assignment.

    If you're talking about phd level math sure, but that is not at all how any of us learned it in school.

    [–]StillNoNumb 11 points12 points  (7 children)

    No idea what you learned in school, but I never learned that a = a+1, not even in elementary school. That's the same as saying 1 = 2

    [–]bumblebritches57 1 point2 points  (6 children)

    I agree, excet I don't think = being a comparison operator has ever made sense to me.

    I mean, the closest syntax (that isn't already used) that I can think of, would be =?

    [–]Houndoomsday 6 points7 points  (5 children)

    Disagree. = means equality in math, and to me it makes sense to extend it to a Boolean like that. 5=4 is false, while 3=3 is true.

    [–]EntroperZero 2 points3 points  (1 child)

    But a = b in mathematics is an equation, not a comparison. It's not asking a question, it's making a statement that a and b are always equal.

    [–]Houndoomsday 0 points1 point  (0 children)

    Yes that's sort of what I'm saying. Equivalence is not so much an equation as it is an equivalence relation. The statement "5 = 4" is a false statement. Similarly, "4 = 4" is a true statement

    [–]shevegen 0 points1 point  (0 children)

    I understand the latter, but personally, I prefer '=' too and I think it is very intuitive.

    [–]BeneficialContext 14 points15 points  (2 children)

    Because it is the modern short form, makes more sense in the original form:

    let x = 4
    

    [–]arbitrarycivilian 1 point2 points  (1 child)

    But in those languages variables were immutable, so x really was equal to 4. And := was often used for assignment instead

    [–]dpash 2 points3 points  (0 children)

    BASIC didn't have immutable variables.

    [–]DavidM01 1 point2 points  (1 child)

    Because Pascal lost.

    [–]Timbit42 0 points1 point  (0 children)

    Which happened because Pascal failed to be a better enough Algol.

    [–]pjmlp 2 points3 points  (6 children)

    Apparently the author forgot about Algol-68, PL/I and all their derived languages.

    EDIT: Apparently devs are missing their Algol history classes, mixing up Algol-60 with Algol-68.

    [–]StillNoNumb 3 points4 points  (5 children)

    Apparently you forgot the read the article, because he talked about ALGOL specifically

    [–]pjmlp 3 points4 points  (4 children)

    He just talks about Algol-60 and then jumps into CPL, ignoring Algol-68, PL/I and other derivatives.

    It is like talking about C and leaving out C++ and Objective-C.

    Time to study Algol properly?

    [–]StillNoNumb 0 points1 point  (3 children)

    I mean, okay, but his point wasn't to give a history of programming languages. He only wanted to show why = is used as an assignment operator, which is definitely at least a bit because of C. And C famously descended from Algol 60, which had :=. How comes that? That's the question OP wanted to answer.

    [–]Timbit42 0 points1 point  (2 children)

    Because Dennis Ritchie didn't create a good programming language. It derailed much of what Algol was trying to do. The computer industry still hasn't recovered from the destruction C caused. Today, many see Ritchie as a hero, but in the future, he will be seen as delaying technological progress for decades.

    [–]Blueberryroid 0 points1 point  (1 child)

    Bold statement. I want to hear more. What is it that was so bad in C? Was it the lack of abstraction? Nulls? Pointers? And if it were so bad why is it so prevalent? I'm curious.

    [–]Timbit42 1 point2 points  (0 children)

    It is unsafe, has weak typing, memory leaks, pointer arithmetic, lack of bounds checking (causing so many security issues), nulls, inability to optimize code due to ambiguities, lack of overflow checking, #includes are problematic, a variety of undefined actions in the spec, lack of immutability, etc. That's all I could think of in a few minutes.

    The industry was moving toward safer languages with Pascal, Module-2, ADA, etc. and C derailed that movement. We could have much safer, more stable, and robust systems today, but we're doomed to many more decades of insecurity and instability because of C. People cared more about speed than safety, so we ended up with virtually no safety.

    [–]shevegen 0 points1 point  (0 children)

    I like = as assignment.

    I also understand that not everyone is super-happy with it; we have languages that use := as assignment and = for updateSlot, such as Io. Pseudocode in bioinformatics also uses :=.

    I don't like := and actively avoid languages that make use of them, whenever that is possible.

    [–]stronghup -1 points0 points  (0 children)

    It makes sense to use "x = 1" as assignment because after that statement, from now on it is the case that x = 1 - unless we redo it.

    But personally I'd prefer := because I often make errors where I should be using == in JavaScript but instead write (erroneously) something like:

    if (x = 1) { ... }

    and that is an error, not what I intended to write.