While I'm certainly no fan of spaghetti code, I think this is an important kind of experience for novices. I, for example, let mentees at work go down a wrong/weird path with their code for a couple weeks when I see bad code patterns or poor choices in algorithms/data structures in order to give us something to discuss and correct later when they start to hit pain points that I, usually correctly, predict they'll hit. I let them know that they're making their life harder, but I don't direct them to change course (some do on their own, others don't). Telling someone who's just learning how to do things the "correct" way (to the extent that there is a singular correct or a small set of correct options) doesn't give them sufficient motivation and experience to actually learn and internalize it. Often you get a kind of cargo cult mentality around the things you teach them since they lack comprehension of why those are good ideas or better ways of organizing code or whatever, or a later rejection of what they're taught because they don't understand the motivation behind it.
Also, letting them go down the path of spaghetti code or confused structures gives an opportunity to teach them refactoring techniques, which even expert programmers still have to apply to systems they develop (most people don't write perfect code on the first pass, and most systems having changing requirements which would render the perfect code imperfect if they did).
> To instruct calls for energy, and to remain almost silent, but watchful and helpful, while students instruct themselves calls for even greater energy. To see someone fall (which will teach him not to fall again) when a word from you would keep him on his feet but ignorant of an important danger, is one of the tasks of the teacher that calls for special energy, because holding in is more demanding that crying out.
It's a quotation that I often keep in mind while helping my kids learn.
When really they just wanted to increment the score variable by 10.
I think the best thing that my CS 101 prof did was always refer to the assignment operator as "gets" so you'd say "eks gets eks plus one" out loud. It really helped divorce assignment and equality in my mind.
It is less jarring to see:
Let x = x + 1
because it could be read: we have a given value for x, now let us replace that value with x + 1.
I remember TI basic has "=" for comparison, and "<-" for assignment, like, 'A<-5'. That one, to me made, the most sense. "Put the value of 5 in something called A."
Some people say a language like Haskell would be no harder, and maybe even easier, for someone with no previous programming or CS experience, than something like C or Python. Comments like that make me wonder if they're right!
(Haskell is a pure functional language. And so has the same reaction as your friend. Variables are immutable. Anything else would be madness.)
A few years back, there was someone who shared here his experience teaching young kids programming with a simplified/visual Haskell and it was pretty cool. It seems kids without programming preconceptions don't find it all that difficult.
When teacher was explaining equations first time. I thought, "this is easy, its just like programming".
I’d forgotten just how confusing those initial concepts like arrays could be.
- I remember when I started, using BlitzBasic, I had a really hard time understanding the concept of arrays.
- A friend of mine, when showing him the statement 'x = x + 1' was confused; surely, x cannot also equal x+1.
- When teaching Python, the concept of function parameters and variable scope is always a struggle.
To some degree, having spaghetti code and all globals is useful for teaching because it 1) gets people excited to program and see something working and 2) demonstrates why you don't want to do those things. I remember when trying to write my first text based CYOA game, I was so excited to add content to it and see it on screen, but also learned very quickly that having to scroll through 20 pages of if statements was not fun, and why functions would help. I'm not sure if someone explaining "encapsulation" to me would have really taken root.
I think there should be a rewrite of the book, for modern languages and development environments, but keep the complexity extremely low, like 70's BASIC was intended.
EDIT: Just looked at https://github.com/coding-horror/basic-computer-games/blob/m... , it actually looks like a pretty good blend of original but with mild improvements.