Hacker News new | ask | show | jobs
by bmalehorn 3456 days ago
I am a systems programmer working at a company with a largely C++ codebase. We don't use Rust.

It has nothing to do with the reasons mentioned in the article or this thread.

Here are a list of requirements for us to use Rust:

  - Does it support all of the following architectures? x86_64, ARM, MIPS, powerPC
  - Does it support soft float?
  - Can it link against uclibc instead of glibc?
  - Can it link against arbitrary C libraries?
  - Can I use a C library's header.h file without having to hand-recode it to Rust?
  - Will the code I write now continue to compile 5 years from now?
Does Rust score a resounding "YES" on ALL of the above questions?
3 comments

It mostly scores a "YES", where there are footnotes. AFAIK all of these things are being worked on.

> Does it support all of the following architectures? x86_64, ARM, MIPS, powerPC

It does: https://doc.rust-lang.org/book/getting-started.html#tier-2. Granted, while tier 2 support is pretty good, it isn't the same level of support as the tier 1 platforms.

> Does it support soft float?

From running `rustc -C help`:

        -C            soft-float -- use soft float ABI (*eabihf targets only)
> Can it link against uclibc instead of glibc?

It can link against musl, but I'm not sure whether that would enable uclibc. Probably?

> Can it link against arbitrary C libraries?

Yes.

> Can I use a C library's header.h file without having to hand-recode it to Rust?

You can use something like rust-bindgen (https://github.com/Yamakaky/rust-bindgen) which will work with a minimal amount of cleanup afterwards in my experience. Still not a resounding yes, though.

> Will the code I write now continue to compile 5 years from now?

Yes. See https://blog.rust-lang.org/2014/10/30/Stability.html for more about the plans/policies/etc.

Great, thanks for the reply and links.

Sounds to me like the current state is "doable," but not "solid." I can convince myself to try it out, but not my whole company. But, maybe this will improve over time.

That seems like a fair summary to me. Several of these items (better interop with existing libraries, for example) came up in the recent 2017 roadmap RFC conversation, and I would expect them to improve in the future.

Also, if you do try Rust and find other issues that would be blockers for your company to pilot a project, I know that the teams have been very eager to get feedback from "systems" shops on what would be needed to get them trying Rust out commercially.

1. Yes. https://forge.rust-lang.org/platform-support.html

2. Yes, though it's kind of awkward.

3. There were some patches in the queue, I forget if/how they landed.

4. Yes.

5. Sort of. You have to rely on a tool to do it; they work reasonably well but aren't perfect yet.

6. Unless you're relying on something with a soundness hole, which we reserve the right to fix, and will be trivial to upgrade for you.

All of that will come after rust gets an ISO standard (like C and C++). Joking aside, C++ will be around forever and to a lesser degree, C will be too. They have 45 years of experience and revision. 50 years from now they'll probably still run the world just as they do today. C++11 and beyond is just as safe as any language. Rust came to be about 10 years too late.
> C++11 and beyond is just as safe as any language.

That's just not accurate. This is UB, despite being done entirely using modern C++ API:

    #include <iostream>
    #include <vector>
    using namespace std;
    
    int main() {
        std::vector<int> v;
        v.push_back(1);
        v.push_back(2);
        v.push_back(3);
        v.push_back(4);
        for (int i : v) {
            v.push_back(5);
            std::cout << i << std::endl;
            v.push_back(6);
        }
        return 0;
    }
I ran it on https://code.sololearn.com/caR4o14MOCWr/#cpp and got this output:

    1
    8519872
    3
    4