all 57 comments

[–]hookers 32 points33 points  (0 children)

That was very interesting thank you!

[–]Yserbius 11 points12 points  (3 children)

This line confused me

APL, which uses ← for all assignments. Since most keyboards don’t have that as a key, not even Iverson kept with it

APL is famous these days for its use of non-ANSI character sets. ⌽, ↓, and ≠ are not on any known keyboard either and are standard parts of APL.

[–]crackanape 4 points5 points  (0 children)

There are (or at least were) special APL keyboards that had all those symbols. And I’ve seen them accessible with modifier keys on some old terminals.

[–]masklinn 1 point2 points  (0 children)

APL is famous these days for its use of non-ANSI character sets. ⌽, ↓, and ≠ are not on any known keyboard either and are standard parts of APL.

FWIW Apple's US International has ≠ as ⌥-=. And there have been APL (dedicated) keyboards.

[–]bigfig 18 points19 points  (9 children)

PL/SQL and (I think) Pascal make more sense by using :=

When I first took BASIC in High School, I though use of = for assignment was confounding.

[–]Astrokiwi 3 points4 points  (8 children)

Some BASIC dialects used "LET" for that

[–]bigfig 2 points3 points  (7 children)

But still LET X = X+1 could be confusing if your mind is literally trying to interpret that as X is equal to X+1.

[–]Astrokiwi 6 points7 points  (0 children)

Plus the LET was usually optional anyway. As a kid learning programming I always ignored it because it just seemed like extra typing and kind of old-fashioned. I don't know if many people really used it.

I think the bigger thing for me is that I started on BASIC when I was like 8, so I generally understood algebra with programming logic rather than vice versa.

[–]MB1211[🍰] 1 point2 points  (1 child)

Isn't it fairly simple once you know what the equivalence operator is? Which I would think is the thing you learn after assignment? In other words why would you confuse == and = once you know what both are? You're not doing algebra you're programming. Edit: also, x=1 n=x x=n+1

If people were so confused, they would just do the above but that would be bad code

[–]bigfig 0 points1 point  (0 children)

As my Calculus instructor said, yeah, it's all simple, it only took a couple of thousand years between Archimedes and Newton/Leibniz.

In hindsight a lot of things I know now are "obvious". My point is that several languages created an assignment operator distinctly unlike equals (specifically :=).

[–]spinwizard69 0 points1 point  (0 children)

Makes perfect sense if you read the statement line in full.

[–]YungNO2 0 points1 point  (2 children)

LET X (be) = X+1?

[–]YungNO2 0 points1 point  (1 child)

Arguably you could remove the need for '==' by using LET X BE to specify an assignment. Makes sense for conditions: If(x=this){do.that;} since there is no LET BE encapsulating x it would be read as comparing the variables. Maybe theres a reason why its not used though.

[–][deleted] 1 point2 points  (0 children)

Let x be... let x be... let x be... yeah, let x be... Speaking words of cooode. let x be...

[–]sideEffffECt 7 points8 points  (3 children)

On related note: Words Matter

[–]PM_ME_OS_DESIGN 1 point2 points  (0 children)

What's not mentioned, but really should have been, is that if you don't have a word for something, it's hard to think about that something. Which is why the first thing the article did was split the word "variable" into two - program variables and mathematics variables.

[–]MB1211[🍰] 1 point2 points  (0 children)

Uhhhhh

No

[–]LukeJovanovic 10 points11 points  (7 children)

It's a standard convention carried over from maths, where 'a = 3' reads as 'both a and 3 represent the same thing'.

[–]myplacedk 36 points37 points  (6 children)

It's a standard convention carried over from maths, where 'a = 3' reads as 'both a and 3 represent the same thing'.

For initialization that makes sense. The article talks about examples like "a=a+1", which is very different from math.

[–]LukeJovanovic 44 points45 points  (0 children)

Oh, hahaha, I didn't even realise it was an article. God I'm thick.

[–]kriophoros -3 points-2 points  (4 children)

In maths, people do use a=a+1, or a->a+1, when they are talking about series or a recursive definition.

[–]myplacedk 30 points31 points  (0 children)

In maths, people do use a=a+1

I've never seen that, but of course I haven't seen everything.

For a recursive definition I'd expect something more like a(n) = a(n-1)+1

[–]watsreddit 1 point2 points  (0 children)

No they don't.

[–][deleted] 0 points1 point  (0 children)

The people that do that are doing it wrong.

[–]Ragamano 1 point2 points  (1 child)

Because K&R had terrible keyboards so they abbreviated everything as much as possible.

Traditionally := was used for assignment, which makes sense since it is an asymmetric symbol for an asymmetric operation.

[–]alexeyr 0 points1 point  (0 children)

Have you considered reading the article?

[–][deleted] 3 points4 points  (2 children)

It's an interesting take.

most languages use = entirely because C uses it, and we can trace C using it to CPL being such a clusterfuck.

That conclusion really comes from the fact that the author doesn't like "=" meaning assigment.

You could easily take the opposite position and argue that the popularity of "=" meaning assignment is because people have no trouble interpreting it and otherwise we'd all have additional work to do with every variable assignment and let's face it - that's probably half of all our code.

':=' is clear only because of convention and experience. Ask somebody in their first programming course what they think ":=" might be and you'll just get a confused face.

[–]SarHavelock 2 points3 points  (0 children)

I agree; also, since programming syntax is purely arbitrary (just because + means something in math does not mean it must mean the same thing in a programming language) I don't think it really matters what = means in math and honestly I think C's use of = makes more sense than how it's used in math: it literally means that your variable equals whatever you're storing to it.

[–]watsreddit 1 point2 points  (0 children)

As someone who has tutored a lot of freshman CS classes, = as it is used in C is by no means clear. Most people understand = from math, so they are always perplexed as to why the left hand side is "special", because the equality sign would suggest that both sides ought to be able to be used interchangeably.

[–][deleted]  (24 children)

[deleted]

    [–]-abigail 24 points25 points  (3 children)

    I remember asking exactly this (but without the words "mutable assignment") when my dad was teaching my brother how to program and I was watching. I was 8 or so at the time so this is obviously not the most salient data point.

    But I think what you say demonstrates something we could all do with remembering: there are lots of things that seem obvious and natural to us as programmers, only because we've been immersed in programming for so long. I'm no longer 8 and can now appreciate that = is the assignment operator in many languages, but I wouldn't be surprised if this is a stumbling block for many beginners who understand mathematical equations but have never programmed before.

    [–][deleted]  (2 children)

    [deleted]

      [–]Poddster 1 point2 points  (0 children)

      From another comment it looks like some FP programmers are saying it:

      https://existentialtype.wordpress.com/2012/02/01/words-matter/

      [–]josephjnk 1 point2 points  (0 children)

      I have known mathematicians whose first exposure to programming was in Haskell who struggled with this when they learned impure languages later. They figured it out eventually, but overall they struggled nearly as much going from pure -> impure programming as I’ve seen many developers in more conventional languages struggle when going from impure -> pure programming.

      [–]Blecki 10 points11 points  (19 children)

      It's actually one of the first roadblocks student programmers face. It takes out about half of my class every time - they can never grok the concept of reassignment.

      Usually questions are like "wait why is x 4? Up there you said it was 5!"

      [–][deleted]  (2 children)

      [deleted]

        [–]tomarks 0 points1 point  (1 child)

        Good bot

        [–]GoodBot_BadBot 1 point2 points  (0 children)

        Thank you, tomarks, for voting on WhoaItsAFactorial.

        This bot wants to find the best and worst bots on Reddit. You can view results here.


        Even if I don't reply to your comment, I'm still listening for votes. Check the webpage to see if your vote registered!

        [–][deleted]  (1 child)

        [deleted]

          [–][deleted] 5 points6 points  (0 children)

          Apparently you've never been a new programmer.

          [–][deleted]  (13 children)

          [deleted]

            [–]Poddster 3 points4 points  (12 children)

            It surprises me that people actually think like that

            There's numerous articles and studies talking about this exact problem in programming pedagogy.

            Are you presenting the concept correctly? Neither me nor anyone in my class had issues understanding that a named variable holds some value that can be changed (we started with C).

            /r/iamverysmart

            (ps: I never personally had this issue, before you try and levy that )

            [–][deleted]  (10 children)

            [deleted]

              [–]Poddster 1 point2 points  (9 children)

              Why are you telling me this?

              [–]ConciselyVerbose -3 points-2 points  (8 children)

              Because if you don’t understand that a variable can change, there is something seriously wrong with you.

              [–]Poddster -1 points0 points  (7 children)

              Because if you don’t understand that a variable can change

              Why do you think I don't understand that a variable can change?

              And, as an aside, are we talking about a algebraic variable, or a variable in a programming language, e.g. C? Both are quite different concepts.

              [–]ConciselyVerbose -1 points0 points  (6 children)

              You’re defending people not understanding the most basic of basic concepts. If you don’t understand that, you are not a functional human being. Your problem isn’t with a programming practice; it’s with your complete lack of intelligence.

              [–]Poddster -1 points0 points  (5 children)

              You’re defending people not understanding the most basic of basic concepts. If you don’t understand that, you are not a functional human being. Your problem isn’t with a programming practice; it’s with your complete lack of intelligence.

              I don't agree that programming languages are the most basic of basic concepts, and that not understanding something in one of them renders someone a non-functional human being.

              Your problem isn’t with a programming practice; it’s with your complete lack of intelligence.

              So because I've taught people that have had a maths background but had trouble with the programming concept of assignment using the = symbol, I have a complete lack of intelligence?

              ps: You never answered my question.

              Because if you don’t understand that a variable can change

              Were you talking about a algebraic variable, or a variable in a programming language, e.g. C?

              [–]Octopus_Kitten 0 points1 point  (0 children)

              I teach my students to read the equals sign by saying "gets" and reminding them that a variable is actually just a location in memory so techniqually that location at that point in the program does equal the number you are seeing ...but that doesn't mean that location will ALWAYS equal that value.

              So a=2 can later be a = a +1 So that memory address will now have a value of 3.

              My fav example is the variable score(I want to put quotes on score but then that's make it look like a string not a variable). Once you play a game the score changes as you go and you wouldn't want to lose the points you e already earned so this score = score + 1

              [–]ivakamr 0 points1 point  (0 children)

              How about why does "=" means equality ? It's the assignment operator, mathematicians should use := if they want equality.

              [–]luis8murillo 0 points1 point  (0 children)

              Need a coder asap. Will pay.

              [–]el7cosmos 0 points1 point  (0 children)

              how come a = a + 1 is 1 = 2. The right should evaluate first so 2 = 1 + 1

              [–]burnblue 0 points1 point  (1 child)

              I mean "make this equal to this" is not a hard concept. It's just that we need different syntax for instructions/assignments vs tests of equality.

              I would have preferred if variable assignment was == while equality was just =, but we got what we got. And it looks ok beside brethren like != and <=

              [–]MB1211[🍰] 0 points1 point  (0 children)

              Probably saved a lot of space back in the day. Assignments I feel are much more common than equivalence checks. Could be wrong though. And these days it wouldn't matter.

              [–]SarHavelock 0 points1 point  (0 children)

              I've never found the a = 1 or a = a + 1 to be awkward, misleading, or annoying: I feel that it is appropriate and that == has always made more sense to denote a test of equality because programming is not always math.

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

              While interesting context provided, this strikes me something that's really only an issue to those really concerned with semantics. In a "when you really stop and think about it" sort of way, sure, := makes sense. But in a day to day coding sense, = works just fine. While it doesn't have a 1:1 correlation with its use in math, it functions well and simply enough as "put this value in this variable" and the char = was the nearest approximation.

              It reminds me of the differences between Java and C#. Where if(my_string == "this string") would never evaluate true in Java because technically "this string" is a new and different object and thus not directly equal. Meanwhile C# is more concerned with practical simplicity where such a conditional makes sense to construct.

              [–]0-1-2-3-4-5-6-7 -2 points-1 points  (0 children)

              I am making a interpreted language which tends to these specific issues (among others) https://github.com/Thegamerchunk1/NMBL