3 ms·
Same. When I was 12ish trying to write a Pac-Man game in basic, I dreaded writing the logic for the 4 ghosts. I'd need separate code for the ghosts at (x1,y1)..
by phkahler 3y ago
Same. When I was 12ish trying to write a Pac-Man game in basic, I dreaded writing the logic for the 4 ghosts. I'd need separate code for the ghosts at (x1,y1)....(x4,y4) and said to my dad it would be cool if I could use xn and yn inside a for loop, but those are just 2 more variables. I wanted n to indicate which one. This seemed kind of weird, but it's what I really really wanted. He grabbed the little basic book and showed me that x(n) was actually a thing!
I think back to this in discussions about teaching. Abstract concepts are best understood when the student has a legitimate need for them. You can explain something all day and have their eyes glaze over wondering why something is important, but if it solves a problem they have it will click in seconds or minutes.
- quirino 3y agoWhen I started programming at 12-13 I had no idea loops or arrays existed and implemented an absolutely criminal Tic-Tac-Toe game. The same year me and a friend were studying for the national Informatics Olympiad and we were completely stumped when faced with a problem that required a list: "How do we know how many variables to declare if we don't know the N beforehand?". (The problem if anyone is interested: https://neps.academy/br/exercise/384 https://neps.academy/br/exercise/384. Given a list of up to 50k distinct numbers (with values up to 100k) and another list of 50k numbers that should be removed, print the resulting list. Time Limit: 1 second.)
- freetime2 3y agoWhen I first started coding, I thought loop structures were confusing and redundant when I could accomplish the same thing with GOTO. So that’s how I implemented all my loops for years until I eventually took a course and a teacher told me I was never to use GOTO again.
- deleted 3y ago[deleted]
- wongarsu 3y agoDijaksta's “goto considered harmful“ is often interpreted as a much broader opinion than it was, but this is a perfect example of what he was against
- User23 3y agoYeah Dijkstra's main objection to goto is that it's really hard to formally define its semantics and even if you do, the formalism is so complex it's hard to reason about. Break and continue on the other hand are considerably easier to formalize.
- matheusmoreira 3y ago> national Informatics Olympiad That brought back a lot of memories... I wonder if there are participation records. The olympiad website isn't responding. I also took part in the astronomy olympiad.
- quirino 3y agoThe OBI website is really great, it's just been down for a couple of days. There's a good chance you'll find records there.
- dubi_steinkek 3y agoThis seems to be a somewhat common occurrence. When I was first learning programming with python I wanted multiple balls in a pong-like game, so after some googling I ended up writing something like `globals()["ball" + i]` until someone mentioned that arrays were a thing I could use for that.
- tambourine_man 3y agoIt’s a recurring thing because programing at its fundamental level is extremely simple. If you have variables, conditionals and loop/goto you can do anything. It’s pretty easy to learn the basics and get much more empowered than you had any right to be. Armed with such power, you will build a slow, unreadable and unmaintainable mess, but you don’t know that yet, because it’s all working after all. But as your lines multiply you begin to misstep on your own code and wonder if there’s a better way to do this. And you then stumble upon data structures, functions, classes, etc. The self-taught road is always more or less like that.
- tugberkk 3y agoI believe this is the way. That is why I sometimes think whether programming can be taught by using shell environment at first. Every command is like a program and you can do a lot without loops. Piping also helps. But maybe piping is not a good way to start, dunno.
- xp84 3y agoShell (and its odd cousin the .BAT file) is interesting because it’s got such wildly different sets of “easy things” and “complex things” compared to almost any language. Write some ASCII to a file - one character in Bash, 2-?? lines of annoying boilerplate in every other language Pick the second item in an array - in Bash, a series of random-looking punctuation I can never recall to even create a true array. In any other language, roughly myArray[1] So I worry that in some cases the student forced to only learn using shell might be bitter once they learned other languages. PS: it’s funny you mentioned loops as a “do without” — I’d say bash is pretty okay with that — as long as you’re looping over a list of files ;)
- WJW 3y agoThis comes up pretty often in (well-designed) video games. Say you have colored doors that can only be opened by keys of the same color. If you put the blue key on the path to the blue door, then players will never learn that you need the color of the key to match the color of the door. But if you put the blue key on a side path and have the player encounter a blue door relatively early on, then they will encounter the door first and cannot progress until they find the key. The frustration at not being able to progress is much more effective at teaching the player about the "colored keys for colored doors" mechanic than any amount of explaining you could have done.
- harrylove 3y agoThis answer unlocked a principle in my thinking about a certain class of problems I’ve been struggling with in a different domain. Thank you!