145
you are viewing a single comment's thread
view the rest of the comments
[-] BB_C@programming.dev 2 points 3 days ago

You can trivially use C libraries in Rust, or any system language that supports the C ABI for that matter, and this includes many hobbyist languages. Zig is not special.

[-] kewjo@lemmy.world 1 points 3 days ago

zig is a bit special in this regard though as it is a c compiler not just using ffi. this means you could swap out gcc, make autotools etc and drop in zig with a build.zig. mostly useful if you want to migrate large code bases as you can incrementally port the parts you want.

if you're picking it up for a new project then yeah this probably doesn't impact you much.

[-] BB_C@programming.dev 1 points 3 days ago

a c compiler not just using ffi.

Beyond what amounts to a packaging difference, what does that even mean?

How do you think zero-cost C ABI support (including fully working cross-lang LTO) works in lang implementations that have that? And how do you think that's different from what Zig gives you?

[-] kewjo@lemmy.world 1 points 3 days ago

from rust docs:

Note: “Zero-cost” means zero runtime cost, not zero compile cost. The compiler does real work — monomorphization and inlining — to make abstractions disappear, and that work shows up as longer build times. See Reducing Compile Time for the trade-off.

most of the benefits come from a shared code base, one compiler (which is insanely fast with incremental rebuilds and can watch files for changes) means changes in the c code reflect in a single build step within seconds. the benefit is primarily for the developer as the compiler output should be relatively similar.

[-] BB_C@programming.dev 1 points 3 days ago

That has nothing to do with what we were talking about. And in any case:

insanely fast

Needs qualification vs. other languages for binaries with comparable runtime performance.

(Hint: you will be surprised.)

with incremental rebuilds

Not special or unique.

and can watch files for changes

Not only not special, but literally exists in all workable build tools. bindgen+build.rs is the Rust version of this.

[-] kewjo@lemmy.world 1 points 3 days ago

I'm not sure what you're talking about then, in zigs case you don't need an exposed ABI to use existing c code?

in terms of performance it will always be ambiguous as implementations are hard to compare across languages, however they use llvm as an alternative to support architectures as they build out their native compiler. in the transition for x86_64 they were seeing up to 70% increase in compile speeds. its still ambiguous as its dependent on their implementation of llvm, though its such a large increase it is still meaningful.

but i say all this as a rust and zig advocate where i would happily choose either over the the majority of alternatives.

[-] BB_C@programming.dev 1 points 3 days ago

exposed ABI

ABI is not something that gets "exposed" or not.

it will always be ambiguous as implementations are hard to compare across languages

Correct.

in the transition for x86_64 they were seeing up to 70% increase in compile speeds

And that was a part of what I was hinting at, because you get >>70% speed-up with Cranelift in most Rust projects. But in either case, faster code generation is not free lunch, hence the mention of comparable runtime performance of generated binaries.

this post was submitted on 15 Jul 2026
145 points (100.0% liked)

Rust

8141 readers
9 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS