• ganymede@lemmy.ml
    link
    fedilink
    arrow-up
    16
    ·
    edit-2
    2 years ago

    Write many small programs as often as you can. That is, write new programs often, and make them small so you learn the full cycle of beginning, middle and end, over and over. This is the best way to learn.

    Learning programming consists of 3 main things (imo):

    1) The problem:

    Learning to break a problem down and solve it in individual steps.

    eg. Fill Car With Gas:

    • Turn Engine off
    • Open fuel cap
    • Get out of car
    • walk to fuel pump
    • etc etc

    This is fundamentally what you will end up telling the computer to do when you write code, breaking a big problem into smaller problems, and smaller problems into individual steps.

    Sometimes before writing a program, we will do the steps manually ourselves first to understand them. Then you write the code.

    Its like when telling your friend how to do something its much simpler when you’ve done it yourself before.

    2) The Machine:

    When you’re first learning its not required to worry about the actual machine the computer is doing. Just to note a few quick things.

    The computer can really only do a few very simple things, almost everything the computer does is literally just combinations of the following very simple things:

    • INPUT - Read a number from somewhere (from memory, from disk, from network, from a previous step)

    • OPERATION - Do something with the number (add, subtract, multiply, compare etc)

    • OUTPUT - Write a number somewhere (to the display, to memory, disk, network, to a subsequent step)

    • Do combinations of any of the above IF some thing is true (eg. number is bigger than 10)

    3) The Language(s):

    To tell our computer friend the steps we want it to do, we need to use a language it understands. Don’t get hung up on languages, in the end most of them have alot of similarities, and learning the core concepts is more important than memorising specific syntax.

    To say this another way, while syntax is important to USE a language, it doesn’t always have a huge bearing on the core concepts underneath. A classic beginner mistake is muddling the language vs the core computing concepts.

    In the end, almost whatever code you write, no matter the language, it ends up doing a combination of those simple steps from #2.

    The job of the language is to make it easy and efficient for a human to tell the computer which combinations of those steps from #2 we want the computer to do to achieve our task. And if the language has done its job, it will hide many of those tiny steps from us, so we can worry about the main steps which relate to our problem.

    Re. first language choice, python is probably a good starting point, since if you use it properly it’s often almost like writing in english to the computer. In the end it doesn’t matter so much as sticking with it, practicing and slowly learning the core concepts. In general any user friendly high level language will have an easy learning curve, Python, Javascript etc.

    General Tips:

    Learn some basic debugging & troubleshooting methods, at first this might just be displaying numbers during calculation steps to check the computer is doing what it should be doing, and then slowly move to more sophisticated methods. Along with basic commenting etiquette etc.

    Avoid stackoverflow like the plague. There is some good discussion there, but if you want to actually learn, you need understanding. And copy/pasting someone else’s code will not give you this.

    Same goes for chatgpt coding, autopilot etc.

    When googling deliberately search for the official manual/documentation, or even a tutorial is fine if it’s unfamiliar or the official docs aren’t easy for you to understand, but absolutely avoid pre-cooked answers on stackoverflow etc as google will also push them on you when googling programming stuff.

    The only exception is if you’re absolutely stuck, when doing learning exercises it’s ok to view someone else’s answer as a ‘solution’, but IMPORTANTLY, do not move forward until you have understood at least 90% of how and WHY they did it. Without that understanding you’re wasting your time, and sometimes you will even find mistakes in those answers, so blindly copying is only hurting you.

    Get onto IRC (or matrix, discord whatever), and TALK with other programmers. Don’t go running to someone every time you stumble, but you can learn ALOT from others when you put in the right amount of groundwork and sometimes you will learn just by seeing other people solving their own problems.