Incase it doesn’t show up:

  • ⸻ Ban DHMO 🇦🇺 ⸻@aussie.zoneOP
    link
    fedilink
    English
    arrow-up
    19
    ·
    edit-2
    17 days ago

    Disclaimer: I actually like C++ the language, I’m reasonably comfortable with it and enjoy it as an upgrade from C. I don’t use much OOP stuff as I’m writing a game using the flecs ECS. So things like abstract classes are mostly absent from my codebase.

    What has been driving me up the wall the last month has been build systems and dependencies: don’t get me wrong; meson is great but the problem is not everyone uses meson. All I want to do is add some library built with cmake as a dependency without needing to rewrite the build system or install it on my OS. Apparently that is too much to ask!

    I’m seriously considering dropping everything and jumping to Rust because of Cargo. Yes I’ve tried setting up conan but not having much fun since the recipes are all third party and out of date anyways

    • boonhet@lemm.ee
      link
      fedilink
      arrow-up
      10
      ·
      17 days ago

      I’m seriously considering dropping everything and jumping to Rust because of Cargo.

      Well if you’re into game dev, ECS and Rust, there’s like a 99% chance you know of it, but just in case you don’t: We have bevy, now with an extra full-time dev (Alice, who’d been working hard at it for years, I think she’s a bigger contributor than the author himself at this point lol)

      • ⸻ Ban DHMO 🇦🇺 ⸻@aussie.zoneOP
        link
        fedilink
        English
        arrow-up
        4
        ·
        16 days ago

        I’ve been keeping an eye on bevy, it looks really cool. I’ll probably make something with it one day when their ECS gets support for entity relationships (which appears to be in the pipeline). A really cool project though, basically looks like everything I’ve wanted out of a C++ engine which I can’t really use due to build system mixing.

    • Doom4535@lemmy.sdf.org
      link
      fedilink
      arrow-up
      11
      arrow-down
      1
      ·
      17 days ago

      Rust’s cargo is great, I’d say it would be best to make the switch sooner rather than later once your code base is established. The build system and tooling alone is a great reason to switch

      • ⸻ Ban DHMO 🇦🇺 ⸻@aussie.zoneOP
        link
        fedilink
        English
        arrow-up
        5
        ·
        17 days ago

        What sucks is I’ve been working on this hobby project for nearly 4 years now. It started in C#, moved to C, now C++. It’s at the stage where a lot of basic functionality has been implemented, with the largest component, the Vulkan based renderer being maybe 1/4 implemented. The core game stuff is ECS based and flecs has a rust binding so migrating that will be easy. Renderer will just become even further from completion. I’m worried that there will be new problems that are maybe more inhibiting, but this is meant to be a fun project and build systems aren’t fun. It’s a difficult balance and I’m not the only person involved, the other person isn’t as convinced by cargo as they haven’t spent days working on the build system

        • CptBread@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          edit-2
          17 days ago

          I’m a gameplay programmer who have worked with Unity and Unreal and I’ve experiment with Rust for gamedev(though only for hobby projects) and for regular code. My conclusions so far is that Rust sucks for gameplay code, for most other things it’s kinda nice.

          The biggest reason is that it’s much harder to write prototype code to test out an idea to see if it’s feasible and feels/looks good enough. I don’t want to be forced to fully plan out my code and deal with borrowing issues before I even have an idea of if this is a good path or not.

          I would say though that because you are using ECS stuff it is at least plausible to do in Rust but at least for my coding/development style it still isn’t a good fit.

          • rhombus@sh.itjust.works
            link
            fedilink
            arrow-up
            0
            ·
            17 days ago

            The biggest reason is that it’s much harder to write prototype code to test out an idea to see if it’s feasible and feels/looks good enough. I don’t want to be forced to fully plan out my code and deal with borrowing issues before I even have an idea of if this is a good path or not.

            There are options for this with Rust. If you wanted to use pure Rust you could always use unsafe to do prototyping and then come back and refactor if you like it. Alternatively you could write bindings for C/C++ and do prototyping that way.

            Though, I will say that this process gets easier as you gain more experience with Rust memory management.

            • CptBread@lemmy.world
              link
              fedilink
              arrow-up
              3
              ·
              17 days ago

              Not really. Unsafe doesn’t allow you to sidestep the borrow checker in a decent way. And even if you do it the Rust compiler assumes non aliasing and breaking that will give you loads of unexpected problems that you wouldn’t get in a language that assumes aliasing…

              Testing something that only has side effects to the local scope is probably not too hard but that isn’t the most common case for gameplay code in my experience…

              Going through another language basically has the same issues as unsafe except it’s worse in most ways as you’d need to keep up to date bindings all the time plus just the general hassle of doing it for something that could have been a 10 min prototype with most other setups…

              Now sure it’s possible that I would have better result after doing even more rust, especially with some feedback from someone who really knows it but that doesn’t really change anything in just general advice to people who is already working on something in C++ as they likely won’t have that kind of support either.

    • geneva_convenience@lemmy.ml
      link
      fedilink
      arrow-up
      3
      ·
      17 days ago

      Brackeys started a series on Godot recently. If you are writing a smaller game GDscript looks attractive and far simpler.

      • Myavatargotsnowedon@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        16 days ago

        They’re mucking it about a little though, like that post when checking if types don’t match ‘! value is type’ can now be ‘value is not type’ which is more readable but not as logical in terms of the language.

      • TheHarpyEagle@pawb.social
        link
        fedilink
        arrow-up
        2
        ·
        16 days ago

        Being a Python simp, I find GDscript just different enough to nag. There’s a lot of QoL stuff they don’t have and aren’t (currently) looking to add in order to keep the language simple. Honestly has me looking to use C# instead.

      • TheHarpyEagle@pawb.social
        link
        fedilink
        arrow-up
        1
        ·
        16 days ago

        Being a Python simp, I find GDscript just different enough to nag. There’s a lot of QoL stuff they don’t have and aren’t (currently) looking to add in order to keep the language simple. Honestly has me looking to use C# instead.

    • magic_lobster_party@fedia.io
      link
      fedilink
      arrow-up
      0
      arrow-down
      1
      ·
      17 days ago

      So things like abstract classes are mostly absent from my codebase.

      I believe the consensus nowadays is that abstract classes should be avoided like the plague even in languages like Java and C#.

      • void_star@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        17 days ago

        I have not heard this consensus. Definitely inheritance where the base class holds data or multiple inheritance, but I thought abstract was still ok. Why is it bad?

        • magic_lobster_party@fedia.io
          link
          fedilink
          arrow-up
          0
          ·
          17 days ago

          In 99% of the cases, inheritance can easily be replaced with composition and/or interfaces. Abstract classes tend to cause hard dependencies that are tough to work with.

          I’m not sure why you would use abstract classes without data. Just use interfaces.

          • Zangoose@lemmy.world
            link
            fedilink
            arrow-up
            0
            ·
            17 days ago

            The way I was taught was that you usually start off with only an interface and then implementing classes, and then once you have multiple similar implementations it could then make sense to move the common logic into an abstract class that doesn’t get exposed outside of the package

            • magic_lobster_party@fedia.io
              link
              fedilink
              arrow-up
              1
              ·
              17 days ago

              I usually break it out using composition if that’s ever needed. Either by wrapping around all the implementations, or as a separate component that is injected into each implementation.

            • magic_lobster_party@fedia.io
              link
              fedilink
              arrow-up
              0
              ·
              17 days ago

              Ask Bjarne to add interfaces enough many times until he gives in.

              On a more serious note, I’m not exactly sure what the best C++ practice is. I guess you just have to live with abstract classes if you really want interfaces.

          • jaybone@lemmy.world
            link
            fedilink
            arrow-up
            0
            arrow-down
            1
            ·
            17 days ago

            Say List is an interface.

            You have implementations like ArrayList and LinkedList.

            Many of those method implementations will differ. But some will be identical. The identical ones go in the abstract base class, so you can share method implementation inheritance without duplicating code.

            That’s why.