• TheEntity@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      6 months ago

      Go is like that abusive partner that gives you flowers and the next day makes you feel like shit. Then another day you go to an expensive restaurant and you tell yourself that maybe it’s not so bad and they still care. And the cycle continues.

      Rust is an autistic partner that sometimes struggles with telling you how much they care, is often overly pedantic about technical correctness and easily gets sidetracked by details, but with some genuine effort from both sides it’s very much a workable relationship.

      • Technus@lemmy.zip
        link
        fedilink
        arrow-up
        1
        ·
        6 months ago

        Yeah but Go has the best error handling paradigm of any programming language ever created:

        ret, err := do_thing()
        
        if err != nil {
            return nil, err
        }
        

        Don’t you just love doing that every 5 lines of code?

          • TheEntity@lemmy.world
            link
            fedilink
            arrow-up
            0
            ·
            6 months ago

            With some sprinkle of libraries such as anyhow and thiserror the Rust errors become actually pleasant to use. The vanilla way is indeed painful when you start handling more than one type of error at a time.

            • Fal@yiffit.net
              link
              fedilink
              English
              arrow-up
              0
              arrow-down
              1
              ·
              6 months ago

              Exactly this. Anyhow makes error handling in rust actually a joy. It’s only something you need to consider if you’re writing a library for others to use, and in that case, it’s good that rust forces you to be very very explicit

        • sunbeam60@lemmy.one
          link
          fedilink
          arrow-up
          0
          ·
          edit-2
          6 months ago

          I do think Zig is better for this kind of thing.

          const ret = try do_thing();
          
          if( ret ) | result | {
             do_something_with_result(result);
          }
          

          The try keyword returns any error up; the if-unwrap works with what came out of a successful call. Normally you wouldn’t have both, of course.

          do_thing would be defined as a union of an error (a distinct kind of type, so it can be reasoned about with try, catch and unwrapping) and the wrapped return value.

    • kaffiene@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      6 months ago

      I think I’d rather code in Go than Rust. But I’m not a great Rust programmer so my opinion may not count. I can code effectively in C, C++, Go, Java, C#, Python, and a few others, but Rust is the only language that I find hard to use. I’m probably just dumb

      • Fal@yiffit.net
        link
        fedilink
        English
        arrow-up
        0
        arrow-down
        1
        ·
        6 months ago

        Are you using an IDE like rustrover? Rust is by far the easiest language I’ve worked with. It makes it so the only way to write code is the right way