• Juice@midwest.social
    link
    fedilink
    arrow-up
    5
    ·
    3 days ago

    Is Rust as close to the metal as C? Seems like there would still be a need for C. I could see Rust replacing Java as something that’s so ceremonial and verbose, but from my limited perspective as a sometimes java dev, having only the most glancing experience with C, it seems like C would be hard to replace because of what it is. Buy I honestly don’t know much about Rust either, I just think JS is so finicky and unpredictable whereas web assembly seems extremely fast and stable.

    • themoken@startrek.website
      link
      fedilink
      arrow-up
      7
      arrow-down
      1
      ·
      edit-2
      3 days ago

      Rust can create native binaries but I wouldn’t call it close to the metal like C. It’s certainly possible to bootstrap from assembly to Rust but, unlike C, every operation doesn’t have a direct analog to an assembly operation. For example Rust needs to be able to dynamically allocate memory for all of its syntax to be intact.

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        6
        ·
        3 days ago

        For example Rust needs to be able to dynamically allocate memory for all of its syntax to be intact.

        Hmm, you got an example of what you mean?

        Rust can be used without allocations, as is for example commonly done with embedded.
        That does mean, you can’t use dynamically sized types, like String, Vec and PathBuf, but I wouldn’t consider those part of the syntax, they’re rather in the std lib…

    • frezik@midwest.social
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      3 days ago

      It’s slightly less close to the metal as C. Array bounds checks are always going to cost you something, for example. However, if you look at the speed of numeric computation in C, Rust, and Go, they’re all in the same order of magnitude performance compared to things like Python or JavaScript (not including things like PyPi, which is C with extra steps).

      • Juice@midwest.social
        link
        fedilink
        arrow-up
        2
        ·
        3 days ago

        Wow thanks so much for breaking that down for me! The discussions I’ve been having here and the information devs are sharing is really kicking me off the fence about learning Rust

        • frezik@midwest.social
          link
          fedilink
          arrow-up
          2
          ·
          edit-2
          3 days ago

          Eh, I’d still go for it. I find the Rust compiler tends to amplify my impostor syndrome–it tells you all the ways you are objectively being stupid. I know that’s not really selling it, but it’s doing that stuff for a reason. I’m especially hopeful that it becomes the standard way to do things with microcontrollers; that’s about the only place I write C/C++ at all.