• bluGill@kbin.social
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    1 year ago

    Is there a language other than rust that is memory safe? I’m using C++ for good reason, and while rust does have some things I find intriguing, those who have experimented where I work have returned to modern c++ (I have not been able to figure out why). What other alternatives do I have that compile to fast code, have a wealth of libraries, and interoperate well with my existing C++?

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

      The reason might be, that you must think a bit different from C++ so it might be a little bit tricky to do the switch. Thouigh, if you know C++ the ownership and stuff should be a bit easier to understand since you probably can figure out what is going on. The reason I learned Rust in the first place was because I had to use C libraries, and I knew rust had good support for that. But, unfortunately I cannot assist you with alternatives to rust, since I stopped looking after I learned rust. 😄

    • BatmanAoD@programming.dev
      link
      fedilink
      arrow-up
      5
      ·
      1 year ago

      That’s an extremely niche set of requirements, largely because interoperating with C++ is, well, a nightmare, and partly because “fast code” means something very different to C++ devs than to most devs who use managed runtimes.

      Also, there are different definitions of “safe”. Rust takes a very C++ style view: it’s “safe” in the sense that UB requires either a compiler bug or an explicit opt-in to something unsafe.

      For other definitions of “fast” and “safe”, sure, most garbage collected languages count. Java, C#, and Go are “fast enough” for most application code, and they mostly guarantee that errors will result in crashes rather than UB. Zig is as fast as C/C++/Rust (and integrates much more easily with C than any other language except C++) and has a very different approach to safety (mostly runtime checks in debug mode that are not included in release mode).