Ask HN: Any Things You Wish You Were Told When Learning Programming?

2 points by subtract-smiles 2 years ago | 4 comments
I'm going to be running a class teaching programming from scratch soon, and I want to make sure I don't confuse my students more than I teach them.

If you have any topics or concepts that made programming a lot easier for you to learn that I could make sure to mention in my class would be helpful.

  • gilch 2 years ago
    If I could send a message to my past self on the topic, I might have told myself to start with Common Lisp, Scheme, Python or Smalltalk (maybe Squeak), rather than the BASIC, C++, and C# that I started with. (C++ was too complicated. BASIC is maybe too primitive by modern standards, although assembly might have been worth learning early. C# was better but had too much ceremony for even a simple Hello World.) I might also tell myself to actually read the textbooks rather than just watch lectures.

    There are so many details one has to get right in one's head to program at all, that non-programming experience doesn't prepare one for. E.g. the assignment operator isn't symmetric like the equality boolean operator (in most languages). This is not how it works in math. The simpler the language you start with, the easier it is to model in one's head.

    Having a simple language with a REPL is super useful for getting this straight--if you don't know what it does, you quickly test the assumptions. Go through lots of small examples. Have the students predict and write down what the output will be, then run it and have them explain why they were surprised. This should help you diagnose where their mental models are wrong. Tell them to assume the bugs live in the programmer's mental model, not in the compiler. Flip the classroom if you need more time for this. (I.e. pre-record the lectures, and have them watch them as the homework, and work on the exercises during class time.)

    Explain the language's memory model. What lives on the stack or on the heap? How are arguments passed? What's a copy and what's a mutation? Diagram on the blackboard. Write assumptions down. Human working memory is extremely limited. The gifted students might have seven registers to work with, when they're concentrating. If they're learning the language itself, or talking to you at the same time, there isn't much left to program with. Those with more average IQ might not have anything left at all. Have them start with pseudocode, and iteratively break it down to the level that it can be mechanically translated into the language. Offload everything you can.

    • gilch 2 years ago
      It occurred to me that ChatGPT (or the like) might be able to help students find their mistaken assumptions without taking as much of your time, at least if it's in a well-known language like Python. Being able to dialogue with these new AIs will probably become an important programmer skill anyway. However, if they use it as a crutch to avoid developing their own mental models, it could be net harmful. An outright ban is probably unwarranted, but they eventually need to be able to code without the assistance. If you have a small enough number of students, you could pair program (another important programmer skill) with each individually.
      • subtract-smiles 2 years ago
        Thank you, this is incredibly useful.

        My day one syllabus as I have it planned is going to focus on programming as a method of breaking problems into smaller problems that can be fed to the computer.

        I plan to cover variables and if statements as well as operators within both of those.

        These tips will be super useful, as I have been worried I'll move too fast for students to keep up with, and nothing is worse than the frustrating feeling of not understanding what's going on but wanting to.

      • WheelsAtLarge 2 years ago
        Don't expect teachers to teach you everything you need to know to become a working programmer. Programmers have to seek knowledge. Best way to do it is to create your own project. Challenge yourself by creating an application that you like but that is challenging enough that you will need to do research to create it from scratch.

        The newest recommendation is to make sure you understand how AI will help in programming. It's changing and will continue to change how programmers work.