4 ms·
The author seems to be under the impression that Rust cannot live harmoniously within the C ABI ecosystem, which is false. To some extent. Rust, due to relying
by dleslie 5y ago
The author seems to be under the impression that Rust cannot live harmoniously within the C ABI ecosystem, which is false.
To some extent. Rust, due to relying on LLVM, is limited by its available targets; and so cannot enjoy the full access that C/C++ can. The same is true for Zig, however, since it does not compile to C.
- kllrnohj 5y agoYeah it was a really odd choice of a "why not Rust" bug since the problem with Rust in that bug applies entirely to Zig as well. So if you can't use Rust because it doesn't have the broad compiler support that C does, you almost certainly can't use Zig either for the exact same reason. And then the article touts Zig using their own in-house linker, which seems inevitable to have less platform support than LLVM will? Zig isn't wrong for doing that, but you can't claim that's a benefit at the same time the problem with Rust is it's lack of fringe system support... :/
- kristoff_it 5y ago> which seems inevitable to have less platform support than LLVM will? ZLD can link for M1 while LLVM can't yet. And Zig can also use lld alongside it to increase the platform coverage. > but you can't claim that's a benefit at the same time the problem with Rust is it's lack of fringe system support... :/ I find it hard to believe that a dispassionate reader could misinterpret to this degree the goal of a sentence written in a chapter dedicated entirely to showcase the limits of rewriting code in another language, be it RIIR or RIIZ. See my reply to the parent comment for the intended meaning of that example.
- matu3ba 5y agoyet.
- zamadatix 5y agoOne could say the same thing about Rust, and at least that language has hit 1.0.
- kristoff_it 5y agoIt's not just a random remark, the self-hosted implementation of the compiler which is being worked on as we speak (type?) has multiple backends, one being the C backend which will be used to simplify the bootstrap process of Zig.
- zamadatix 5y agoAgreed, and Rust folks have been working on a gcc backend to get off the llvm monoculture too. As much as I lean on thinking Zig will achieve it first it seems unfair to make claims about things that haven't been done in a language that hasn't even been finalized as reasons it's better than a stable language in the same boat at the moment.
- kristoff_it 5y ago> The author seems to be under the impression that Rust cannot live harmoniously within the C ABI ecosystem, which is false. The author is not under any such impression. The key point is that Zig can cross-compile C/C++ code, while Rust can't. If you have a Rust project that depends on C code, you will have to put in some work if you want to compile it for a different target. That's a pretty big difference in practice. The point about the Python package example is not to say that Zig can get on platforms where Rust can't, but rather that the C infrastructure that we all use is not that easy to replace and every time you touch something, regardless of how decrepit and broken it might have been, you will irritate and break someone else's use case, which can be a necessary evil sometimes but not always. This is a point I made in the section of the blog post dedicated to explaining the limits or rewriting code. > since it does not compile to C. Give it some time, it will.
- dleslie 5y agoZig itself doesn't cross compile C/C++ code, LLVM does the work for Zig. > If you have a Rust project that depends on C code, you will have to put in some work if you want to compile it for a different target. Rust is built on LLVM, and so its toolchain can also cross-compile C/C++ code. There are crates for that[0], and projects inspired by that idea[1]. > Give it some time, it will. Given enough time mountains become valleys. Zig doesn't compile to C now; and won't be mature and field-tested for a decade or more. 0: https://crates.io/crates/cc https://crates.io/crates/cc 1: https://www.build2.org/ https://www.build2.org/
- steveklabnik 5y agoYou're splitting hairs in a weird way. rustc cannot compile C code. zig can. That they delegate to LLVM is immaterial. "This crate calls out to the most relevant compiler for a platform, for example using cl on MSVC."
- kllrnohj 5y ago> You're splitting hairs in a weird way. rustc cannot compile C code. zig can. But why do I care? I don't use rustc directly, the build system of choice does. And very few of the major build systems have an issue handling multiple languages. Cargo (rust's build system) supports build scripts and the community has already created C/C++ compiler hooks such as https://github.com/alexcrichton/cc-rs https://github.com/alexcrichton/cc-rs rustup and cargo also provide easy cross-compilation support, too.