Hacker News new | ask | show | jobs
by xsmasher 1798 days ago
They need a consistent framework to understand what is happening - "variables are like little boxes where you can put a number or some letters" and "The equal sign lets you change what is in the box."

x+=1 just complicates the situation; use x=x+1 to avoid adding more special rules for now.

This stuff is teachable, but it doesn't help that the framework is very different than the similar-looking expressions from math class, where "x=1" followed by "x=2" is not allowed.

1 comments

Thank you. So many have become blind to how weird the syntaxes of programming languages are when not used to them.
It’s nearly impossible to remember what it feels like to not know this information. Often the best programming teachers are people who recently learned the material, for that reason.
I remember exactly my first time learning to code as a kid, the book I used used the "box" analogy for variables and it worked well. It was fairly uneventful experience, I just worked through the exercises at my own pace and was through the book in a couple of weeks.

The problem with learning to program in a classroom environment is that one kid may find exercise one difficult, another kid may find exercise three difficult, etc, the probability that any kid will get 'left behind' at some point is high. Classrooms are pretty bad places for learning.

In my case I remember choosing x = x + 1 in my examples for this reason, as well as writing print as a function for consistency.