I’ve been wanting to learn how to code for a while so I figure now is as good a time as any to start. I downloaded VS code on my laptop for python but I don’t really know end product I should try to code and I also am just bad and barely know what I’m doing. Does anyone here have any advice on what to code and how best to learn?

  • blankmind@lemmy.world
    link
    fedilink
    arrow-up
    19
    ·
    1 year ago
    • Hello World
    • Read a file
    • Write a file
    • Read a file and loop through it line by line, printing each one (for loop or equivalent)
    • Program that consists of 2 or more source files

    What I’m getting at is instead of a full program, write code snippets and small programs. In doing this eventually an idea for something larger will pop into your head.

    • James@lemmy.ca
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      1 year ago

      In addition to what this guy said, don’t just use libraries to skip steps when writing small programs.

      For example when parsing a file you will often use the split and strip functions in python, but learning how to implement these by yourself will teach you more.

      To really learn fundamentals you should try and implement most operations yourself. It’s why in my opinion C is a better language to start with, because it forces you to learn the fundamentals.

      • Max-P@lemmy.max-p.me
        link
        fedilink
        arrow-up
        4
        arrow-down
        1
        ·
        1 year ago

        I’d say it depends on the learning style. For some people, it’s a lot less demotivating to start as just plumbing libraries together to get the end result than starting from the deep end. Same debate as starting with ASM vs starting with Python.

        • James@lemmy.ca
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          I see your point, but I would almost argue that starting out with all these shortcuts available in high level languages is ‘jumping into the deep end’ itself.

          When a newbie sees obscure error messages in some of these libraries they might not have any idea what they mean or why they were triggered. My opinion is that having a smaller set of tools to start is actually simpler despite being able to do less with them.

          I’m slightly biased because I started with C 😅

          • Max-P@lemmy.max-p.me
            link
            fedilink
            arrow-up
            5
            arrow-down
            1
            ·
            1 year ago

            Started with C++, definitely wasn’t easy. I ended up giving up and revisiting a couple years later and PHP/HTML was a fair bit less to take. I did end up revisiting C++ and making an archive format for my game engine. These days I definitely start by the low level, even libraries I jump to the low level features/long form before going to the nicer abstractions for the sake of understanding what’s going on under the hood. It’s definitely valuable too.

            Just pointing out different styles of learning exists, OP can choose whatever fits better for them. I’ve known people that good completely demoralized because it was a bit much to take to think about how big an integer is in memory and arrays and whatnot. Especially if you approach it with making games, focusing on player moment and map scrolling can be more intuitive to learn the basics and slowly migrate to lower level things. I have friends that started with 6502 or Z80 assembly (good ol’ Ti 83+ calculators) and they liked that way better because it made them appreciate what compilers really do better. Really dependent on the person.

            I advocate for whatever works better for the learner, whatever makes them not give up and whatever keeps them going.

            • abhibeckert@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              1 year ago

              Started with C++, definitely wasn’t easy. I ended up giving up

              I made it about as far as std::cout << "Hello World!"; and couldn’t figure out wtf cout was or progress from there.

              Eventually, nearly a year later, I started over with a simpler language (Basic) and maybe five after that I realised my IDE just wasn’t setup right - so cout literally did nothing at all.

    • slazer2au@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      This is a good start.

      My latest python script loads my monthly banking CSV, arranges the columns in the correct order, assigns categories based on the merchant, and finally exports the data to a new CSV.

    • groucho@lemmy.sdf.org
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Yep! And then read argv for command-line parameters + a parser. File IO + command-line controls gets you a shell of a utility to work with. Then grab a package you like the look, bring it into your project, and do something with it (image manipulation, network stuff, whatever…)

  • Max-P@lemmy.max-p.me
    link
    fedilink
    arrow-up
    6
    ·
    1 year ago

    Been coding for 17 years, started when I was 13. A few advices in no particular order:

    • Don’t let yourself get demotivated. It can take a while before it clicks and you feel like a real programmer. That’s fine! My fiancée is coming up to 3-4 years, and she’s barely starting to feel competent at her job. Stuff is hard, and the people you see online with massively deep knowledge has been at it for a really long time, or at the very least, has a lot of experience coming up to that.
    • Code quality is important, design patterns are important. But what’s more important is coming up with something that works: don’t get demotivated by people telling you your code is bad. Take the advice, consider the improvements, learn about the value of said improvements. But getting a project working, even if it’s horribly slow, even if it doesn’t work well, is a success. You made a thing, and it works! Celebrate the victory!
    • It’s very easy to become overwhelmed by the size of a task. Take a deep breath and deal with things one step at a time. Everytime you’re stuck, try to divide up the problem into smaller and smaller steps until you figure it out.
    • Try to work on projects that are fun for you. If you’re not into gaming, don’t make a game, even though it’s a good starting point. Try to find small utilities you wish you had, and make programs to help you with those tasks. It helps feeling rewarded for your efforts rather than feel like you’ve completed a throwaway project for the sake of learning. I got into this because I wanted a website, and so I learned how people make websites. If games are your thing, there’s nothing wrong with starting with something like Godot or Unity or some other free game engine. Heck, if you’re having troubles with a spreadsheet, learn how to make Excel macros.
    • Most programming concepts are portable between languages. Everything related to algorithms, how you approach problem solving, will work mostly the same in other languages.
      • If you feel like you just don’t vibe with a language, it’s worth trying another one for the sake of trying. Establish parallels between them, learn the differences and how it makes you feel about your development experience.
    • If you get overwhelmed and don’t go anywhere, don’t give up. Allow yourself to take breaks, come back to it later. Go at it at your own pace. Having fun makes it a lot less of a chore.
    • Another good way to start is by modifying other people’s code for your needs. Got an open-source software you like but you’d like to switch things around, even just for fun? Figure out how to compile it, make some changes. Observe how it’s made and take inspiration from that.

    Also, there’s embedded programming languages in a lot of things. Many games come with embedded languages to do things, often called “scripts”. Heck, for just dicking around, you could install ComputerCraft for Minecraft, and automate some stuff in-game with the turtles. I’ve seen a fair amount of people get into coding that way: start with just simple things and you’ll find yourself wanting more.

    Did I mention, try to have fun?

    • TerribleJokes@lemm.eeOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Wow thank you for all the suggestions! My friend taught me some of the basics a few months ago but I got busy and had to stop coding for a bit but I still remember quite a bit of what he showed me but again that’s mostly the very beginner functions. I’m a big fan of fighting games, so would unity be good for potentially making one of those?

      • Max-P@lemmy.max-p.me
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        I’m a big fan of fighting games, so would unity be good for potentially making one of those?

        Unity, Godot, SDL, there’s some pretty good Python game libraries as well especially if you’re going for 2D. They’re all pretty good options, as long as it’s easy for you to find documentation and code for. Unity’s a little heavy, I’d recommend maybe starting with Python.

        You also have the option of making it for Android if you want to be able to easily show it off to your friends.

        Fighting game should definitely be within reach especially if you’re going for 2D like Street Fighter!

  • troye888@lemmy.one
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    Back in the day before university (around 6 years ago) I got recommended a mooc(massive open online course) by the university of Helsinki. I used this course to get started with learning to program, and to find out whether it was something for me. It has been some time, and it seems they update the course but I hope it can help you too in learning. Here is the link: https://java-programming.mooc.fi/. It really starts from 0, with setting up te environment which is nice. It is in java using the netbeans ide which some would call antique, but in my opinion that does not really matter to start to learn.

  • 14th_cylon@lemm.ee
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    this might be what you are looking for. you get complete course - lessons, homework, and environment to upload to and evaluate these homeworks. work at your own pace.


    https://pll.harvard.edu/course/cs50-introduction-computer-science

    Course description

    This is CS50x , Harvard University’s introduction to the intellectual enterprises of computer science and the art of programming for majors and non-majors alike, with or without prior programming experience. An entry-level course taught by David J. Malan, CS50x teaches students how to think algorithmically and solve problems efficiently. Topics include abstraction, algorithms, data structures, encapsulation, resource management, security, software engineering, and web development. Languages include C, Python, SQL, and JavaScript plus CSS and HTML. Problem sets inspired by real-world domains of biology, cryptography, finance, forensics, and gaming. The on-campus version of CS50x , CS50, is Harvard’s largest course.

    Students who earn a satisfactory score on 9 problem sets (i.e., programming assignments) and a final project are eligible for a certificate. This is a self-paced course–you may take CS50x on your own schedule.

    • TerribleJokes@lemm.eeOP
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      That course looks amazing! I’m definitely going to try to find some time to start that soon and learn a lot more!

  • RAM_DOS@programming.dev
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 year ago

    I’m still learning but what got me hooked (and still hooks me) is finding tasks that I would like to make easier for myself (changing file names, outputting a simple but interesting data analysis to a file), general amusement (creating a list of curse words and the looping through the list and printing f strings with them), visualizing data. Keep it really simple. I would recommend messing around with little projects, googling how to do stuff but absolutely intersperse that with taking the time to learn why things are doing what they are or how they are doing it.

  • Mischala@lemmy.nz
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    I would go for something simple ish and build from there.

    One thing I used to build every time I was learning a new language was a dice roller for DnD. It had to be able to roll a d4 d6 d8 d10 d20 and percentile.
    You can then expand it to do combinations or formula of dice like “roll 4 d6 and sum the highest 3”

    Only a suggestion, good luck and welcome.

  • yarn@sopuli.xyz
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    If you’re good with learning via books, then I would recommend Python Crash Course. It assumes you know nothing about programming and has a good reputation as a teaching resource.

  • Hangry @lm.helilot.com
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    1 year ago

    Do you have a virtual machine, or a filesystem that you could mess with?
    A good project idea would be to manipulate files on your system. Sort them, duplicate them, add programmatically one line to their content. The possibilities are plenty and you can see the result of your code.
    Besides that, look for tutorial repositories on Github (or codeberg.org).
    Last but not least, VSCode is my personal favorite, but you could check out PyCharm for beginning, as it has more features out of the box.

    • 14th_cylon@lemm.ee
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      A good project idea would be to manipulate files on your system. Sort them, duplicate them, add programmatically one line to their content.

      you really think this is good advice for someone who just downloaded their first ide and are asking what to do next? i think you skipped few steps ;)

      • Hangry @lm.helilot.com
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        1 year ago

        This is why I said it should never be done outside of a VM or sandbox. But you are right, this is playing with fire haha.

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

          that’s not the point. the point is person first has to learn how to print hello world and few other things, before they get to manipulating content of the filesystem.

          it is like if person asked “so i don’t have a driving license and have no idea how to drive a car, what should i do to change that?” and you would reply “well there is this cool racetrack where people are driving their muscle cars at 100 mph and they really know their stuff, you should join them!”

  • ziviz@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Some of the projects that pushed my own learning were very small things to help my school or work. When I was younger I had to do 100 FOIL equations and show my work. I did not want to do that all by hand and wrote a program to do it. If you got something super repetitive but not super hard, that would be a perfect project.

  • Pink Bow@burggit.moe
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Program that inputs a completed Sudoku board. To keep it simple the input will be a single string that contains the digits for each row (top to bottom, left to right). First read the data into an appropriate structure, Next, print the board to the console. Finally, verify whether it’s solved correctly. Bonus: List mistakes.

    • Yoruio@lemmy.ca
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      While I agree that Pycharm is a much better IDE for python in general, I would argue that vscode is a better learning tool, as it doesn’t abstract away things like virtual environments, pip, and packages.