4 ms·
> X equals X plus one? That’s not math. That’s a lie. That's really interesting... My wife, who has no real mathematical background had the EXACT same reaction
by donatj 11mo ago
> X equals X plus one? That’s not math. That’s a lie.
That's really interesting... My wife, who has no real mathematical background had the EXACT same reaction when I was trying to teach her some simple programming. I tried to explain that equals in that context was more of a storage operator than a statement that said line is true. She found it very frustrating and we gave up on the endeavor shortly thereafter.
I've personally always had a soft spot for languages like TI-BASIC that use a storage operator rather than overloading = so for example:
X + 1 -> X
I wonder if I should try a functional language with her.
- SeanDav 11mo agoIt is not a lie it is just apparently familiar notation that actually has an entirely different meaning. It is not an equation, it is an assignment. X := X + 1 is perhaps less confusing, even if meaning the same thing.
- npteljes 11mo agoThat's exactly right. Looking at the Assignment Operator Wiki page, it's also clear where these notations come from. I think an easy way to look at it, for someone coming from a math background, is to think of programming lines as instructions, instead of statements. x=x+1 can be then read as "let x be x+1", and that's it. https://en.wikipedia.org/wiki/Assignment_(computer_science) https://en.wikipedia.org/wiki/Assignment_(computer_science)
- sodapopcan 11mo agoAlthough in Erlang it's closer to an equation with assignment being a side effect. `=` is the pattern matching operator. Eshell V15.2.6 (press Ctrl+G to abort, type help(). for help) 1> X = 1. 1 2> X = X. 1 3> 1 = X. 1 4> X = 2. ** exception error: no match of right hand side value 2 5>
- antonvs 11mo agoIt’s not really such a different meaning, it’s just shorthand for something like: X’ = X + 1 DELETE X X = X’ Even if you treat it as “storing a value in a slot”, a comprehensive model of the operation needs to model the fact that the value of the slot changes over time. So another way to look at it would be: X_t1 = X_t0 + 1 …except that “X” is shorthand for “the latest binding that uses this name.”
- npteljes 11mo agoPascal also had := for assignment, if I remember correctly. I disliked it, to be honest, = is pretty much universally accepted in the IT world to mean "assign to". I don't think this is something that keeps someone from programming. If it does, then the other 100000 hoops won't be better, every trade has its "why the fuck is this the way it is" moments. If you'd still try programming with her, I think you could start with a visual programming thing. Maze from Blockly Games is a simple online logic game that can be overcome with visual programming. No need to register or anything. The levels get progressively harder, as it teaches to apply programming concepts, and makes the player combine them. As a programmer, I found the game really fun, and I think it's suitable for beginners as well, seeing how for example LEGO used a very similar system for its programmable sets. https://blockly.games/maze?lang=en https://blockly.games/maze?lang=en
- jacquesm 11mo ago> I don't think this is something that keeps someone from programming. Not everybody is wired the same way. That exact thing happened to me, it was some kind of mental block. And when that fell away I found the rest of programming to be fairly easy.
- npteljes 11mo agoThanks for sharing your experience. I guess in a case like this, even trying another language can work.
- davidsainez 11mo agoI highly recommend How to Design Programs. I recall being repeatedly mind blown working through the book. It was great fun. The authors start by composing pure functions. IIRC you get quite far before you have to do any mutation. Take a look! https://htdp.org/2003-09-26/Book/curriculum-Z-H-5.html https://htdp.org/2003-09-26/Book/curriculum-Z-H-5.html
- ngriffiths 11mo agoI think it makes more sense in languages where you use the "let" keyword. Then it sounds like assignment, though you still have to get comfortable with the X being on the right side too.
- macintux 11mo agoI've shared it here once recently, so might as well again. I gave a talk at Midwest.io (sigh, such a great conference, shame it faltered) building Erlang from the ground up, starting with the = sign and the implications (side effects?) of it being a runtime assertion of truth in addition to a binding. https://youtu.be/E18shi1qIHU https://youtu.be/E18shi1qIHU
- marcosdumay 11mo agoYes, people with mathematical background tends to fare better with declarative languages.
- jacquesm 11mo agoThis blocked me from understanding computer programming for 3 years. I thought of 'variables' as immutable and the fact that they were not didn't really click at all. Once I mentally transitioned from 'it's a label attached to a value' to 'it's a named box which holds a value' life got a lot easier. I was 15 when it finally clicked (on a TI programmable calculator...).
- galangalalgol 11mo agoI wonder if haskell would have made more sense to you at the time with everything being immutable.
- jimbokun 11mo agoOr maybe Erlang.
- jacquesm 11mo agoThe answer to that is surprisingly simple: no. Because Haskell didn't exist at the time. Neither did Erlang. But LISP did, but was just too expensive and memory hungry for mere mortals such as me. I had to learn all this on a shoestring budget working an 8 hour job and barely having left over enough money for food after rent, taxes and insurance. It took a long time before I was able to afford a floppy drive, much less a half decent computer, one that would be able to run LISP. And those language packs weren't cheap either and open source wasn't really a thing yet (but shareware actually was).
- lysace 11mo agoThat is fascinating. I guess I got through that when I was 7 on a pass-me-down ZX81 from a relative who just had upgraded to a Spectrum (I assume). I mentally called bull when reading boragonul's story because: a) BASIC has a REPL b) Kids back then had near infinite patience/time. c) These computers came with pretty good manuals explaining BASIC There was very little external stimuli. As an example: TV broadcasters in Europe were literally mostly shut off during the day to save power. Radio was on all day, but it was 99% boring adult stuff.
- tmtvl 11mo agoThat's a funny thing to get hung up on, though I can understand it. I suppose that's the downside of some programming languages going with the worst assignment operator. If they didn't they could use = for (numerical) equality tests. If your wife has a strong mathematical background you could also show her some logic programming like Prolog or Mercury. Also, various ways of assignment: Pascal style: x := x + 1 Scheme: (set! x (+ x 1)) Forth: x 1 + x !
- jasperry 11mo agoAm I wrong to be skeptical that this was a thought author had at 8 years old? I don't doubt that 8-year-olds can learn programming and advanced math, but even the brightest 8-year-old would still be in the "sponge" stage. It's hard to believe they would have a sufficiently fixed idea about algebra to be troubled that X = X + 1 is "wrong".
- SatvikBeri 11mo agoKids can be flexible but also rigid about the most random things. My two year old gets really annoyed if I use the wrong spoon to stir my tea, saying certain spoons are only for food or cereals. I don't know where she got that – it's definitely not a practice we ever enforced!
- isaacremuant 11mo agoIt's a common Tactic to pretend children are some sort of tabula rasa full of innocent wisdom that can be use to prove points. It's ridiculous, usually fake and hide the biases of those who nurtured them to believe whatever they believe, even if it's by pure imitation. So you're absolutely right to call BS.
- rramadass 11mo agoYeah; the author is full of it - https://news.ycombinator.com/item?id=45896992 https://news.ycombinator.com/item?id=45896992
- brabel 11mo agoMutation should be an advanced topic in programming teaching. Even in procedural languages. It should be seen as an optimization technique you only use when analysis has shown that to be the only way to solve a difficult bottleneck. Using mutation as a basic tool in programming was a mistake.
- zelphirkalt 11mo agoYes, see SICP (Structure and Interpretation of Computer Programs).
- brabel 11mo agoI saw it. That’s how I know it.
- ghssds 11mo agoI think it's mental rigidity. In BASIC, the = symbol means both assignation as in X = X + 1 and equality as in IF X = 3 THEN 'Do something and it's as natural as 'to dust' meaning both removing the dust and adding dust, depending on context, and 'to sanction' meaning both to approve and to punish. And the Prolog way seems all good too. There are more than one way to think about things.
- overhead4075 11mo agoI explain "X equals X plus one" as though each variable has an implicit version that increases whenever it's written to or as time goes on, but we can only access the lastest version. For example X = X + X is really Xv2 = Xv1 + Xv1
- igouy 11mo agoCuis Smalltalk x ← x + 1 Although you'd need to type x _ x + 1 and it might copy/paste as x := x + 1
- mncharity 11mo ago> She found it very frustrating [...] I wonder if I should try a [different language] with her Or, perhaps, preprocess left-arrow to equal? Customizing a language to taste. Especially for shallow syntactic issues. Like "no multi-line string literals allowed ... I'm sorry, that's just not ok". Or "ok kid, what nicknames would you like to give the keywords today"? When programming for just fun, I'll sometimes go "this aspect of the language bugs me - I could of course just live with it... but here, I think it will be more fun not to". So for recent example, a few lines of recast.js ast tweaking, and I could use infix unicode mathematical symbols as javascript functions. I wonder if one could teach programming by build-your-own language. Perhaps even of the video-scanned desktop variety. "Draw a circle around your toys to create a collection. Label it with a letter. Now you can sort/filter it by..."
- themafia 11mo agoTell her there are transparent subscripts on each use of =. x(0) = 1 x(1) = x(0) + 1 There's no way to reference the subscripts. They're implicit and the language manages it for you. Ask her to think of the Kronecker delta function and it's definition.