• xav@programming.dev
    link
    fedilink
    arrow-up
    87
    arrow-down
    1
    ·
    2 months ago

    I have decades of C++ experience. I have never met any C++ developer who hasn’t shot himself in the foot regularly with this damn language.

  • red_tomato@lemmy.world
    link
    fedilink
    arrow-up
    48
    ·
    2 months ago

    The problem with C++ is that it has so many odd quirks that are difficult to learn. Sometimes these quirks are addressed - at the expense of adding new stupid quirks you need to learn.

  • SinTan1729@programming.dev
    link
    fedilink
    English
    arrow-up
    47
    ·
    edit-2
    2 months ago

    My first ever big boy language was C++ (after Basic, and Logo, does anyone remember that lol). I was in middle school, tried to self-learn from learncpp.com, only to realize that I had mostly learned C, with cin-cout instead of printf-scanf. So I just decided to migrate to C. Nowadays, I mostly code in Rust, Go, and Python. But my experience with C has been extremely helpful. Can’t say the same about C++ though.

    • historicaldocuments@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      2 months ago

      Try the c++23 standard. There’s been a lot of cross pollination. Contrived example follows:

      #include <format>
      #include <numbers>
      #include <print>
      #include <string>
      
      int main(int argc, char *argv[]) {
          double pi = std::numbers::pi;
          std::string fstr = std::format("{}, {:>.2}, {:>.5}, {:>.10}", pi, pi, pi, pi);
          std::string h = "Hello";
          std::string w  = "World";
          std::println("{}, {}!", h, w);
          std::print("This won't have a {},", "newline");
          std::println(" but this will add it."); // Add a newline.
      
          // Can't put a non-constant string as the first argument to
          // print or println so they can be checked at compile time.
          std::println("{}", fstr);
          return EXIT_SUCCESS;
      }
      
  • Feyd@programming.dev
    link
    fedilink
    arrow-up
    21
    ·
    2 months ago

    C++ is my favorite language I’ve ever programmed in and is not even close, but I spent way too much of my time on code reviews because I couldn’t trust almost anyone I worked with not to create dangling refs, memory leaks, etc

  • copacetic@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    15
    ·
    2 months ago

    To be clear, the language itself is usually not the big part. You also have to learn the eco-system, libraries, packaging, debugging, etc.

    (C++ is still a very “comprehensive” language though)

  • dragnucs@lemmy.ml
    link
    fedilink
    arrow-up
    10
    ·
    2 months ago

    There is a difference between learning a language and be productive with it, and with mastering a language. Being a good software developer is another thing.

  • mercano@lemmy.world
    link
    fedilink
    arrow-up
    7
    ·
    2 months ago

    C and C++ ask the programmer to deal with things themselves that other more modern languages do for you in the language runtime Memory management would be the big one. It’s more to wrap your head around, but if you can do it, there’s potential for more performance. In my mind, it comes down to a trade off between development time versus CPU time, and CPU time is a lot cheaper these days.

    Signed, a Java dev

  • xav@programming.dev
    link
    fedilink
    arrow-up
    8
    arrow-down
    4
    ·
    2 months ago

    I have decades of C++ experience. I have never met any C++ developer who hasn’t shot himself in the foot regularly with this damn language.

    • anon_8675309@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      2 months ago

      Developers are the problem. They get language feature envy and so the language they use gets pushed to include the new feature. It’s why a lot of devs hate languages like Go because Go is highly resistant to change. So languages like C++ and C# end up with so many features you can’t possibly know or master all of them.

      For some fucking reason devs don’t want to use multiple languages.

  • lacethespace@sh.itjust.works
    link
    fedilink
    arrow-up
    3
    ·
    2 months ago

    I spent few years using it professionally and mentoring others, but never felt comfortable with it. Small eternities spent fighting the language constructs and solving typing puzzles. My take away is that I could just barely fit the C++ in my head and then there’s no room for anything else. I’m done with it for good.

  • SinTan1729@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    2 months ago

    My first ever big boy language was C++ (after Basic, and Logo). I was in middle school, tried to self-learn from learncpp.com, only to realize that I had mostly learned C, with cin-cout instead of printf/scanf. So I just decided to migrate to C. Nowadays, I mostly code in Rust, Go, and Python. But my experience with C has been extremely helpful. Can’t say the same about C++ though.

    • jjj@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      1
      ·
      2 months ago

      I think there is something to be said for keeping a language simple, though. The basic semantics of a language should be comprehensible to everyone, let the standard library have all the wacky stuff someone wanted decades ago. (macros - the lisp kind, not the C kind - make this easier)

  • andicraft@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    2
    arrow-down
    5
    ·
    2 months ago

    nobody should have to use c++ anymore now that rust and zig exists

    header files are an invention of the devil

    • Valmond@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      2 months ago

      Header files are a thing of beauty! Languages that can’t abstract away definitions suck (or are like script languages, which is fine for scripting).

        • Valmond@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          1
          ·
          2 months ago

          What do you mean? For me, a definition is declared once, in its entirety, and that’s it.

          Declaring it in several places makes no sense of course (for me at least) just include the header and voilà!

      • jjj@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        1
        ·
        2 months ago

        What do you mean by “abstract away”, and what about it is exclusive to headers?

        Eg most languages have something like a trait or interface wherein you can put a list of definitions (optionally with a default aka “inline” implementation) which are then actually implemented elsewhere. This is considered useful by everyone because it allows multiple implementations to be associated with 1 name. They are generally not desired in cases where only 1 implementation will ever be written.

        AFAIK the only use case where headers accomplish the same is if they’re treated as documentation for an API that could be implemented by any library.

        Admittedly certain programming styles benefit immensely from headers, despite the drawbacks to “design as you go” programming.

        • Valmond@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          1
          ·
          2 months ago

          I like c/c++ headers because you can put the “code” in one file, and use the header file in your others where you need access to that code. And you can do that on a compile level. No need to for example compile a c# library that you’ll then use.

          In c# (for example) you’ll include all the code in another file, when you just need one function. In c++ you include only all the definitions, if that makes sense.

          In c# it quickly becomes a garbled mess IMO.

          Sure, you can make libraries, but make libraries for every file? That’s not optimal either.

          So I guess I like it as it lets you split up code on a lower level, very convenient IMO.

  • xav@programming.dev
    link
    fedilink
    arrow-up
    4
    arrow-down
    10
    ·
    2 months ago

    I have decades of C++ experience. I have never met any C++ developer who hasn’t shot himself in the foot regularly with this damn language.

  • xav@programming.dev
    link
    fedilink
    arrow-up
    1
    arrow-down
    8
    ·
    2 months ago

    I have decades of C++ experience. I have never met any C++ developer who hasn’t shot himself in the foot regularly with this damn language.