• @colonial@lemmy.world
    link
    fedilink
    36
    edit-2
    1 year ago

    I’m a big fan of Rust.

    • Excellent tooling. The package/build manager (cargo) just works, the compiler’s error messaging is simply unmatched and the IDE story is excellent thanks to rust-analyzer.
    • Rich ecosystem. There’s a crate for almost anything you could need, and endless piles of learning resources.
    • You get the speed and low-level control (if necessary) of C/C++ without all the pain and legacy baggage.
    • The community tends to care a lot about correctness and API design, which is reflected in both the core language and the ecosystem. Rust doesn’t try to hide complexity and pretend things are simple (like Go) - instead, it gives you the tools to manage it head-on.
      • Example: if a function can fail, then it returns a Result and you have to explicitly handle the possibility that something went wrong. There’s no forgetting a null check and slamming face-first into a NullReferenceException or segfault in some other part of your code.
    • It’s expressive. Iterators, generics/traits and other language features make it easy to communicate what’s going on to both the machine and other humans. Even the syntax is designed to support this - you can tell a lot just by looking at a function signature.

    Obviously it’s not all perfect, however.

    • Compile times can drag you down. (rustc is always getting faster, of course, but it’ll probably never be as fast as Go or JVM/NET.)
    • It can be difficult to read at times, especially when code starts leaning heavily into generics and lifetime annotations.
    • Speed and control comes at a cost. No garbage collector means that anyone coming from a managed language (which, hello, that was me) is going to have to rewire their brain to deal with lifetimes, ownership and mutability XOR aliasing. You eventually develop an intuition for how to structure your code to play nice with the compiler, but that takes time.
    • New language features can take a long time to be stabilized and released. The advantage is they tend to be baked all the way through from day one, but the slow pace can be infuriating, especially when big ecosystem advancements are hung up on key additions.
    • @ProtonBadger@lemmy.ca
      link
      fedilink
      81 year ago

      And much time is saved from debugging. It makes a lot of sense that we let the computer/compiler keep an eye on lifetimes, allocations and access so the code is much more correct once it compiles.

      I feel like my old colleagues and I have spent a far too large part of the last 20 years chasing memory issues in C++. We are all fallible, let the compiler do more.

    • @floofloof@lemmy.ca
      link
      fedilink
      English
      2
      edit-2
      1 year ago

      I like the way the compiler doesn’t just tell you there’s a problem, but also gives you advice on ways you may be able to fix it. That’s a smart compiler.

      And I like the way I can write something that runs fast but not feel faintly anxious all the time I’m doing it.