I’m trying to learn programming and something I struggle with the most is trying to separate code mentally into chunks where I can think through the problem. I’m not really sure how to describe it other than when I read a function to determine what it does then go to the next part of the code I’ve already forgotten how the function transforms the data and I get stuck trying to figure out the solution. So instead I’ll often cludge something together just to make it work but I don’t feel like I made any progress. Has anybody else run into this issue where they struggle with abstracting code from text to mental instructions?

Edit: Thank you all for the suggestions and advise. I wish I could reply to everyone but there’s been a lot of good information given and I have some ways now to try and train my brain to think about how to break down the code. It’s also a little reassuring knowing I’m not the first to have these same struggles.

  • SendPicsofSandwiches@sh.itjust.works
    link
    fedilink
    arrow-up
    10
    ·
    1 year ago

    It’s a lot to take in at first, but the problem isn’t that you’re really doing something wrong or that you’re lacking some piece of information. You just need to actually write more code. It will help you understand why something is set up the way that it is, and also help things make a lot more sense. Once you have that foundation of experience, a lot of other things fall into place on their own for lack of a better explanation. In other words: practice makes perfect

    • Nommer@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      How long would you say it took you before getting a fundamental understanding? I ask because I’ve been at this on and off for years but I always end up quitting because after a few months I just don’t see any progress happening. I’m still forgetting things I learned 3 or even 4 times like how to do a for each loop.

      But as you said it just takes practice. I’ve tried to find challenges that I could do and everything is just so overwhelming I have idea where to start. I see tutorials say to make a tic tac toe game or a calculator or to contribute to open source code. Which is good I suppose but all of it feels too advanced and I get lost on how to begin. For reference I’m currently learning html, css, and JavaScript. Advent of code was okay when I tried but once I got past the first handful of challenges it quickly went way over my head with sorting algorithms and how to make maps out lists for the elves to move or whatever.

      • nous@programming.dev
        link
        fedilink
        English
        arrow-up
        7
        ·
        1 year ago

        I’m still forgetting things I learned 3 or even 4 times like how to do a for each loop.

        I have been programming for decades now and still have to look up how an if statement works in bash - or other similar things, especially when switching between languages. It takes 5 seconds to look up and remember so I would not bother worrying about it. Far better to know when you need to use an if or for loop and quickly look up the syntax then to know the syntax but not when to use it.

        I see tutorials say to make a tic tac toe game or a calculator or to contribute to open source code. Which is good I suppose but all of it feels too advanced and I get lost on how to begin.

        Break problems down into simpler problems, then break those down into simpler problems until you have a trivial problem you can solve. Then build up from there. Like take a tic tac toe game - lots of things to consider that can all be dealt with in isolation. Like rendering the game to the screen, that is one problem you can start with, and can be broken down even further to maybe how to draw a grid to the screen, which again can be broken down to how to draw a box or line.

        You might even want to look at the book " Think Like a Programmer: An Introduction to Creative Problem Solving by V. Anton Spraul" which goes into this way of thinking in more detail.

      • Kissaki@feddit.de
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        Contributing to existing projects as an introduction is very hit or miss. Project and task complexity vary immensely, supporting docs and guidance are most often non existent.

        I love Advent of code as a concept, but I agree - at least the ones I worked on - have a steep difficulty/scope curve.

        Something like a tic tac toe game is great because it is visual, interactive, and iterative as well as relatively small in scope. Any project you have a personal interest in and that has some or most of those properties is great.

        The Web technologies HTML css and js are great to get into programming but I feel like it’s bad for teaching software development as software engineering, because it doesn’t guide towards or ensure structuring and good practices. Which I thought you were talking about at first, but I guess you’re not at that point yet with on and off beginnings.

        Going back to your original description, functions encapsulate a work unit. Use it to name and define behavior so that you can combine and hide away complexity in a defined and obvious manner. Separation makes overall complexity manageable because you can look at subsection of it.

        How did your tic tac toe game go? Was that something that worked out well?

        Have you looked at other projects? For example other tic tac toe implementations and how they did it? Which can be hit or miss in quality and readability of course.

        In my opinion the best way to learn, or environment to learn, is teaching or/and guidance through a good senior. The second best is interest and personal projects. Even if it’s small hacks or projects, and even “unfinished” projects can give experience and knowledge.

      • Crul@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        1 year ago

        How long would you say it took you before getting a fundamental understanding?

        I would say years, as with any complex activity.

        I’m still forgetting things I learned 3 or even 4 times like how to do a for each loop.

        You can forget in 2 different ways:

        1. Forget how to use something, so you need to look how to do it.
        2. Forget that something exists, so you cannot even look for it because you are not aware it’s a possibility.

        You will forget-1 everything which you don’t use on a daily basis. That’s what internet is for. Forgetting in the 2-nd sense is much more rare and you should do something if that’s the case.

        all of it feels too advanced and I get lost on how to begin

        This is a bias most of us have, you overlook how easy is for you to do things that previously were impossible and focus on how hard are the things you still don’t know how to do. And computing is so complex right now that there always be “infinite” things you don’t know.

        Try showing what you know to someone who doesn’t know how to code and you will get an idea of how much you have learnt :).

        Anyway, I don’t really have good advice :/, just wanted to confirm that what you feel is expected. Good luck!