From a language architecture standpoint and not an ecosystem standpoint, what might be some things where you’d really not want to use Rust, either because of some limitation that prevents it from doing it or just because it’d be massively annoying to write to the point of significantly reduced productivity? What about Rust makes it unsuitable, and what language paradigms are the best for it?

I hear a lot about how the things that Rust is not good for, JIT compilation with a garbage collector is usually the best solution, and vice versa. How true is this?

  • AgreeableLandscapeOPM
    link
    fedilink
    arrow-up
    2
    ·
    3 years ago

    Rust does not like undefined behavior.

    Can you elaborate this? Is it like when your program wants an integer between 1 and 5 and it gets -420?

    • southerntofu
      link
      fedilink
      arrow-up
      3
      ·
      3 years ago

      Can you elaborate this? Is it like when your program wants an integer between 1 and 5 and it gets -420?

      This is a matter of correctness: does your program behave as expected? (Rust can help with this with eg. types to prevent integer overflow)

      What we mean with undefined behavior is it’s actually undefined. There’s quite a lot of constructs you can use in C which will get compiled to different instructions by the compiler and behave in unexpected ways. Or even when compilers agree on a certain way to do it, use-after-free and other patterns can lead your program to taking unpredictable turns.

      So, just because your program doesn’t have undefined behavior doesn’t mean it’s correct. But if it’s correct, it can’t have any undefined behavior. If you’ve ever noticed how most programs written in C/C++ seem to have hard-to-reproduce bugs (eg. desktop environments) you’re very likely to have encountered undefined behavior in the wild.