• kubica@fedia.io
    link
    fedilink
    arrow-up
    0
    ·
    13 days ago

    The weird part of rust is replacing straight forward semicolons from other languages with the more verbose .unwrap();.

    Just kidding, don’t lecture me about it.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      12 days ago

      The amount of people on the internet seriously complaining that both Rust error handling sucks and that .unwrap(); is too verbose is just staggering.

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

        I will say this: for me, learning rust was 80% un-learning habits from other languages.

        People tend to not like it when they have to change habits, especially if those took a long (and painful) time to acquire.

        In this particular case, this is the same complaint Go faced with its form of explicit error handling. And Java, for that matter.

        Honestly, Rust does a killer job of avoiding checked exceptions and verbose error hooks by way of the ? operator, and requiring all possible match branches to be accounted for. If you embrace errors fully, by using Result<> and custom Error types, your program gets a massive boost in robustness for not a lot of fuss. I recently learned that it gets even better if you embrace enum as a way to define error values, and make sure it implements useful traits like From and Display. With that, error handling code gets a lot more succinct, permitting one to more easily sift through different error values after a call (should you need to). All of that capability far exceeds any perception of clunkyness, IMO.