Have you ever heard that Rust is difficult and has a steep learning curve?

In this blog post, the author will explain why he believe that is wrong and, in some cases, easier than some other programming languages.

  • Anders429@lemmy.world
    link
    fedilink
    English
    arrow-up
    8
    ·
    1 year ago

    I think this article is spot on. A lot of people I know were turned off from Rust because the compiler was so much stricter than what they were used to, which tends to frustrate experienced devs quickly, in my experience. But it’s not that the compiler is overly strict; the errors it catches would almost always become problems later. It’s just that reducing the number of compile-time errors doesn’t feel like progress as much as reducing the number of run-tine errors, because you haven’t actually run the program successfully.

    Once you use Rust for a long time, you adapt to the compiler and can get things to compile much quicker. That’s where the satisfying part of programming in Rust comes. You get to where you write code and it just works, first try.

    • GuybrushThreepwo0d@programming.dev
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      1
      ·
      1 year ago

      You get to where you write code and it just works, first try.

      Eh, I write plenty of Rust code that doesn’t work. But at least I haven’t had a segfault in a while

    • Open World@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Yeah, I think Rust ends up front-loading so many of the problems/frustrations you’d end up having, at the benefit of having much better, safer, and performant code in the long run.

    • GuybrushThreepwo0d@programming.dev
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      2
      ·
      1 year ago

      You get to where you write code and it just works, first try.

      Eh, I write plenty of Rust code that doesn’t work. But at least I haven’t had a segfault in a while

  • tatterdemalion@programming.dev
    link
    fedilink
    English
    arrow-up
    7
    ·
    1 year ago

    The first figure showing color-coded effort is close, but I would say Rust’s blue “business logic” portion should be smaller. Pattern matching and linear data types can encode a state machine so much more accurately than C. You’re more likely to get the business logic right the first time if you know what patterns to use.

  • snaggen@programming.devOP
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    I think the author is correct about the compile / test ratio being drastically shifted in rust vs other languages. One thing to have in mind regardng this, is that in larger companies testing may be performed by a dedicated team. Hence, a shift to rust will give the impression of a much higher workload for the developers. In reallity the workload should be pretty much the same since the bugs from testing still needs to be fixed, but that will be spread out over a larger time span due to going by the test team first.

    • taladar@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      5
      ·
      1 year ago

      The other thing to consider is that any bug that makes it to the testers or even to production code takes so much more effort to fix than if you had caught the same bug early on. No communication overhead with the testers, no fixing corrupted data in the live database, no scheduled downtimes,…

      • Open World@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        I couldn’t agree more. Dealing with bugs in test/production is so much worse all across the board in my experience.

    • taladar@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Go is very different from Rust. I haven’t fully learned it but I have tried to find some bugs in some of the Go tools we use and Go code makes it very hard to find the actual business logic in between all the low level stuff that would be abstracted away in Rust.

  • tiny_fingers@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    As someone learning Rust right now (reading through The Book and doing rustlings), most of the basic concepts have been straight forward and easily carried over from the languages I currently work with.

    However, as someone who hasn’t touched c or c++ in the 20 years or so since university, the ownership stuff has made my brain hurt. That section in The Book has been a real slog for me and I’ve had go through that section several times now, but still haven’t truly ‘got it’ yet.

    All that said, I do like the compiler helping ensure I’m writing good code and in that regards, I can see why the author says that Rust is easy. Instead of beating your head on a desk trying to track down some obscure bug, with Rust, there’s a good chance it’ll tell you where the bug is and why it won’t let you compile (at least based on my beginner understanding).