I rather write garage code than using slop

  • Buddahriffic@lemmy.world
    link
    fedilink
    arrow-up
    16
    ·
    5 hours ago

    I suggest you also spend some time learning about data structures and algorithms. That’s one of the things that separate university trained computer scientists from many self-taught or college trained programmers. Spending some time learning about how the hardware works is also worthwhile. Just stick these on your todo list, they aren’t necessary to understand to program, but the quality of what you make will improve if you understand these.

    There’s a lot of other ways you can increase your depth or breadth of knowledge, but IMO those are the two biggest.

    And for software design in general, the biggest thing I’d emphasise is modularization. Try to break up your program into different pieces that fit together. Like for a game engine, you could have the renderer framework as one module, input handling as another, and game logic as a third. Then, if you want to make a different game, you just swap out the game logic module and you’ve got a different game using the same renderer and input modules. This is essentially what libraries are.

    • toastadar@lemmy.zip
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      41 minutes ago

      Any refs you recommend for data structures and algorithms, stuff recommended to me on YT is surface level or 150 npm Install tutorials

      • Buddahriffic@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        17 minutes ago

        Nothing specific offhand as I went to university for it and even that was a long time ago.

        My top suggestion would be if it’s available through one of those free online university programs, that would probably be the best bet (aside from attending a good university computer science program).

        Other than that, my usual method for learning something programming-related is to just do a web search. Not all sources will be great but there should still be some decent ones.

        Just did a search myself, and while I haven’t delved into exactly what is on this site, it does appear to be pretty comprehensive at least, plus has sample problems (which helps turn things from “something you read” to “something you know”):

        https://www.geeksforgeeks.org/dsa/dsa-tutorial-learn-data-structures-and-algorithms/

    • starelfsc2@sh.itjust.works
      link
      fedilink
      arrow-up
      2
      ·
      1 hour ago

      imo these are things you learn if you really want to understand coding deeply and write good code, not if you just want to make some software. I also don’t know if you would really understand what you’re seeing unless you know why you need it, at least that was the case for me. I majored in CS and most of my understanding still comes from how I actually ended up using things, and most of it never fully clicked until a couple years of using it.

      • Buddahriffic@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        48 minutes ago

        Somehow I got into an efficiency/performance focused mindset pretty early on, so I appreciated the algorithm analysis when I got to it (though I thought then and still do think that big O notation simplifies it a bit too much… Those dropped terms can be just as or even more significant as the final term when it comes to typical data sets, but it’s still useful in understanding how an algorithm scales).

        And I’d say that just going over the existing data structures and understanding their strengths and weaknesses can help just by being aware something exists. Like if all you know are arrays and linked lists, you’ll probably struggle a bit to handle key/value pairs. And then, once you learn about them, you might use them for everything and then wonder why your code runs so slowly.

        And the main reason why I’d like more people to be aware of how to be good programmers is that there seems to be a lot of people that just go from “something I’m doing as a hobby” to “something I’m doing for money” or “a large hobby project that has been picked up by the community”. And software quality has been dropping at a similar rate to how much hardware is improving.

        But you’re right that, without the greater context, a lot of it can be confusing and can beg the question of “why do I need this?”

        • starelfsc2@sh.itjust.works
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          14 minutes ago

          Yeah just for me personally I also really liked making things as efficient as possible, but I thought data structures and algorithms were lame because I had zero context around it.

          Maybe that’s just how it’s taught though, because there are really cool examples of what data structures to use and why. For instance if you have npcs with attacks that all have different cooldowns, and a central system that applies the attacks, what’s the best way to store it? A min tree is O(log n) on insertion, so that seems best, but what if it’s very likely an attack is invalidated and you need to remove it before it triggers? Lots of interesting concepts to consider there, instead of just “this does x and has y properties, so it’s good in this use case.”

    • PotatoesFall@discuss.tchncs.de
      link
      fedilink
      arrow-up
      1
      ·
      1 hour ago

      algorithms and data structures are overrated IMO. No average programmer is manually writing sorting algorithms or reversing linked lists. And if you do need something like that, you can just google it

      • Buddahriffic@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        40 minutes ago

        Even if you aren’t implementing them directly, it can help to just understand how a library you’re using implements them. Most data structures have scenarios where they are the best option and other scenarios where they are the worst option. Which one you pick can be the difference between an operation taking under a second vs minutes or hours. Hell, even if you pick the correct structures overall but layer them poorly, you can see a difference like that.

        It’s like adding an understanding of engineering to woodworking skills. Sure, a carpenter could probably build a house frame on their own, but it takes engineering knowledge to minimize the amount of wood used while still being sure that it won’t fall over if the wind gusts to 100 km/h or it snows during winter.

  • Caveman@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    4 hours ago

    Best of luck, my pro tip is that learning by doing is a lot faster. Text based tic tac toe is a great project to get the fundamentals down. Text tetris is next for code organisation, reusable functions, interfaces and whatnot. After that it’s off to the races.

  • charmed_electron@programming.dev
    link
    fedilink
    arrow-up
    14
    arrow-down
    1
    ·
    8 hours ago

    Wishing you the best of luck! My unsolicited advice after nearly 30 yrs of C/C++ and a couple Qt apps is that it’s not too soon to start studying the Qt docs. Understanding how Qt apps are architected is a separate learning exercise from the syntax of the coding language itself.

  • ImgurRefugee114@reddthat.com
    link
    fedilink
    arrow-up
    8
    ·
    8 hours ago

    Over 15 years of low level c and modern c++ programming for resource-constrained systems; tutored it too. Feel free to DM if you have questions or get confused about anything.

  • Hugh@programming.dev
    link
    fedilink
    arrow-up
    15
    arrow-down
    1
    ·
    10 hours ago

    Is this your first programming language? If so I strongly recommend Harvard’s CS50 course. It’s mostly in C but it’s very well taught and you learn enough fundamentals that you can quickly transition to another language.

    • 14th_cylon@lemmy.zip
      link
      fedilink
      arrow-up
      7
      arrow-down
      1
      ·
      9 hours ago

      It is on YouTube, and you can enroll it here - https://www.edx.org/cs50 - and submit your homeworks and have them machine graded.

      All for free. The homework part is not necessary, but you will get that feeling of being in school and stressing about deadline ;)

    • dfyx@piefed.social
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      1
      ·
      8 hours ago

      I would say the main downside of C++ is that it carries around a lot of baggage from the last 40 years. Even if you decide to use a modern standard in your own code, you’ll have to deal with libraries that can’t use many of the new features because they need to stay backwards compatible with old code bases. Also, a lot of tutorials and examples still look like they are from pre-C++11 times.

      I recently started a project that would have been a great fit for C++ (simple 2D game engine + editor) but the way Qt has to reinvent half the standard library, GTK basically asks you to write plain C and gtkmm had some other issues that I can’t even remember, all the fun of working on the project was gone. I decided to switch to C# (which I use for work anyway) and Avalonia and so far it’s going well. Not being able to use C++ still nags at me anyway. I would have loved to get more comfortable with modern C++ but I just couldn’t keep up the motivation.

      I’ll try again for the next project.

      • diaphragmwp@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        7 hours ago

        carries around a lot of baggage from the last 40 years

        cries in C stdlib

        I hate null terminated strings. Though the rest of just C without the “pluses” is nice. Nobody really kept adding new things unlike in C++, it’s just mostly the good old stuff.

        Anyways

        GTK basically asks you to write plain C

        From my perspective, glib is all possible languages at once implemented as C macros. What you are actually writing is technically valid C, but I would consider it “glib language” lmao.

      • ImgurRefugee114@reddthat.com
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        3 hours ago

        it carries around a lot of baggage from the last 40 years.

        Cppfront2 is an interesting experiment that looks at an approach to solve that problem without a hard break. While my C nostalgia is offended by the syntax, I’m quite fond of it. Bjarne’s pet topic of ‘profiles’ is another but hasn’t landed much yet.

      • unknownuserunknownlocation@kbin.earth
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        7 hours ago

        Agree on that. It cuts both ways. On the one hand, it gives you access to a fuckton of libraries so that you can chose the one that best fits your use case. On the other hand a lot of those libraries don’t use modern C++. And I haven’t even started on things like the win32 API, which is essentially a C library masquerading as a C++ API.

        That’s essentially the thing with C++: when you’re chosing which library to use, the level of C++ should be a factor in the decision making process, along with things like performance and functionality. And if I do end up using a library that was written for an old C++ version, I create wrappers for the things I use the most to bring it to the level of C++ I’m working with. Sometimes it’s also interesting purely from a learning perspective. That’s what I did for a lot of the win32 APIs I worked with.

        You mentioned tutorials - I learned C++ from learncpp.com, and I couldn’t recommend it more. It does a really good job at going deep into the technical stuff, but also understanding and using the most modern features of the language, as well as best practices.

  • Remus86@lemmy.zip
    link
    fedilink
    arrow-up
    1
    ·
    6 hours ago

    The Cherno also has good videos on C++, although he assumes you have an understanding of the most common programming concepts.

  • justme@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    6
    ·
    10 hours ago

    the good old “hello world” program. even with decades of experience you always come back to it to solve problems :)

  • istdaslol@feddit.org
    link
    fedilink
    arrow-up
    9
    arrow-down
    5
    ·
    12 hours ago

    As C++ is a superset of C, I reckon you should start with C, as many concepts of C++ are translatable to C, which is what the first C++ compiler did.

    I still use fprintf instead of cout because it feels more “proper”

    • observantTrapezium@lemmy.ca
      link
      fedilink
      arrow-up
      6
      ·
      9 hours ago

      I very strongly disagree. It’s practically a superset for backwards compatibility reasons but modern C++ coding patterns are vastly different to C. Modern English is kind of a superset of Shakespearean English, but you don’t need to know it for most daily tasks. C++ is much more elegant and safe when avoiding C patterns. C has its place and I use it sometimes, but the two should absolutely not get confused because of the name and compatibility.

      • Possibly linux@lemmy.zip
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        1
        ·
        6 hours ago

        C++ is a lot of things but elegant and safe are not words that come to mind. C++ has far more issues than regular C.

        Best option would be to use something with memory safety

        • observantTrapezium@lemmy.ca
          link
          fedilink
          arrow-up
          2
          ·
          5 hours ago

          Well, I mentioned safe in the comparative degree. Modern C++ could be actually safe if you restrict yourself to a subset of it, that’s sometimes not really practical. I do think that things are improving and with C++26 it’s becoming way easier to write perfectly (memory-)safe code that’s also (subjectively) elegant.

          • Possibly linux@lemmy.zip
            link
            fedilink
            English
            arrow-up
            1
            ·
            5 hours ago

            The C++ spec is absolutely massive. Nothing says elegant like a million different ways to do something.

            Python works pretty well and doesn’t have to much overhead. Sure it doesn’t have the same performance as C/C++ or Rust but most of the time you don’t need millisecond level code.

            • observantTrapezium@lemmy.ca
              link
              fedilink
              arrow-up
              1
              ·
              3 hours ago

              I do agree and I think it’s wise to narrow C++ down by a lot, and that is a choice you can make when working on a new project.

        • Supercrunchy@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          5 hours ago

          Modern C++ changed a lot!

          You are supposed to use shared_ptr (automatic reference counted pointer) and unique_ptr(statically checked unique pointer) and not create raw C-style pointers anymore. It still has a lot of weird niche cases that need to be avoided, but memory management is definitely much easier, so in many ways it’s safer at runtime than C, while being still much more obscure than C.

          I still agree with you that a more modern language would be even better, especially for learning!

    • one_old_coder@piefed.social
      link
      fedilink
      English
      arrow-up
      10
      ·
      10 hours ago

      I reckon you should start with C

      I tried that 20 years ago and it was a massive waste of time. Spend a few days to understand pointers, then embrace modern C++ with the STL, it’s safer and more productive.

      Also cout is dead, you can use print, println, and format now.

    • ColdWater@lemmy.caOP
      link
      fedilink
      arrow-up
      11
      arrow-down
      1
      ·
      12 hours ago

      That’s what I tried to get started with, but I wanna make programs with qt6 and the qt creator doesn’t support it so c++ it is

      • mamg22@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        arrow-down
        2
        ·
        10 hours ago

        Props to you for learning C++, its a neat powerful language, although it has grown quite overcomplicated through the years.

        Though if you want something a bit easier, you can also use Python for Qt development through the PySide6 library. It is one of the officially supported Qt languages alongside C++ and JS. I’ve personally used it for a few programs and it works wonderfully, it is one of my favorite ways to make GUIs for myself, it just works™

    • mkwt@lemmy.world
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      9 hours ago

      As C++ is a superset of C

      This is not true. Both ISO C++ and ISO C have have features that are not available in the other language. Therefore, there is no subset or superset relationship.

      I would tweak this recommendation. If you want to start with C, consider writing C-style code into .cc or .cpp files, and compile as C++. You will therefore be learning “C++ with functions only” as opposed to “C with classes.”

    • mmmm@sopuli.xyz
      link
      fedilink
      arrow-up
      4
      ·
      12 hours ago

      At uni I was taught C++ first (all the basics, logic 101, control flow, pointers, etc). Then I was taught data structures with C the next period (linked lists, stacks, queues, a tiny bit of trees…). Then I found out I sucked at maths and switched to graphic design!

      All in all OP is in for a hell of a ride - yeah you could just start with C but they could start with C++ too so just to get the feel of it.

      • istdaslol@feddit.org
        link
        fedilink
        arrow-up
        1
        ·
        11 hours ago

        True, it was just a recommendation because for me it made more sense this way around. Like objects are just structs with function pointers and some compiler magic to ensure private and publicness, polymorphism is just unions etc.