I’ve been trying to learn a system language because it would enable me to access a whole new world of possibility for games, tools, and potential projects. My main problem when learning the language are:

  • can I write modern C++ code using the newer standards and still compile with libraries from older standards?
  • how do I even organize a C++ project? Look at the linked project, the CMakeList.txt is so hard to understand, the syntax looks so hard to write.
  • how do I install dependencies? You’re going to laugh at me, but I always used languages with package managers and I looked again at the linked project, and they write a whole CMakeList.txt to import ImGui (GUI library I wanna try) but if you compare the structure of the files, it’s different from the ones on the repository of ImGui.

As you see there are a lot of problems and it pains me to not be able to solve them because Rust is so unfun to use and work with! Do you think I should try C++, carry one with it?

Thanks, hector.

    • quilan@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      7 months ago

      C++ is great with many things, but a consistent build system is Definitely not one of them. Additionally to note, when doing CMake stuff, it’s generally best to stick to the modern way of doing things (targets, rather than a slew of global properties); it ends up being a lot easier to develop as projects grow and other dependencies are added.

      • lysdexic@programming.devM
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        7 months ago

        Additionally to note, when doing CMake stuff, it’s generally best to stick to the modern way of doing things

        I’d add that the so called Modern CMake is well over a decade old. There is no excuse for people to choose to be miserable.

        Personally I prefer calling “Modern CMake” as simply CMake, and the old way of using CMake as “you’re doing it very wrong, invest 5 minutes going through a tutorial.”

        • quilan@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          7 months ago

          I don’t disagree at all there, however there’s an absolute glut of websites showing the bad way of doing things. For a person brand new to C++ though, I find it generally important to make a distinction, so one doesn’t pick up the first thing seen and learn bad habits.

      • hector@sh.itjust.worksOP
        link
        fedilink
        arrow-up
        1
        ·
        7 months ago

        I think I’m gonna use Bazel anyways, the basic stuff and configuration I need is there. It’s super easy to say what part of your code depends on which.

        You can use globs to compile every files and be aware of every head according to a regular expression… yeah I really like it.

        • lysdexic@programming.devM
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          7 months ago

          I think I’m gonna use Bazel anyways

          Last time I checked, Bazel barely supported externa libraries and had zero support for shared libraries. Admittedly that’s been a while, but those are pretty basic features to be missing.

          IDE integration is also critical, and Bazel has nothing to show for in this regard.

          Lastly, most of the benefits that Bazel advertises can be had with CMake by simply switching it’s generator to something like Ninja, which is trivial and supports compiler cache tools such as ccache right out of the box.