Incase it doesn’t show up:

  • ⸻ Ban DHMO 🇦🇺 ⸻@aussie.zoneOP
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 year 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

    • Doom4535@lemmy.sdf.org
      link
      fedilink
      arrow-up
      0
      ·
      1 year 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

    • magic_lobster_party@fedia.io
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      1 year 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
        1
        ·
        1 year 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
          ·
          1 year 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.

          • jaybone@lemmy.world
            link
            fedilink
            arrow-up
            0
            ·
            1 year 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.

            • magic_lobster_party@fedia.io
              link
              fedilink
              arrow-up
              0
              ·
              1 year ago

              If the lists have shared components then that can be solved with composition. It’s semantically the same as using abstract classes, but with the difference that this code dependency doesn’t need to be exposed to the outside. This makes the dependency more loosely coupled.