Hacker News new | ask | show | jobs
by antoinealb 1952 days ago
A good reason is that if you want interop with other languages, C is still the lingua franca of ABIs. All scripting languages have a way to interact with C through some form of FFI mechanism. I guess you could write it in Rust and maintain C bindings to it, but that would be painful.
2 comments

Not really. We wrote a content-addressable-storage backup solution in rust[0], and one consumer is QEMU for doing backups of VMs, so we expose C bindings of our rust code[1] and use them in QEMU[2], effectively having rust async stuff handled by QEMU co-routine library. It wasn't exactly complicate or the like, required a bit of "plumbing code" but that's OK.

Allowing to get (relatively) easy C bindings is a goal and feature of rust, at least the project itself provides and maintains the rust-bindgen crate[3][4].

Having a bit bigger and slightly complex project like a backup server done in rust is such a relief compared to C or similar languages. Good speed, fast start up times like C but refactoring is really a breeze lots of safety is guaranteed and more time can be spent on fixing the semantic bugs.

[0]: https://pbs.proxmox.com/docs/introduction.html#introduction

[1]: https://git.proxmox.com/?p=proxmox-backup-qemu.git;a=summary

[2]: https://git.proxmox.com/?p=pve-qemu.git;a=blob;f=debian/patc...

[3]: https://github.com/rust-lang/rust-bindgen

[4]: https://rust-lang.github.io/rust-bindgen/

Interesting, I stand corrected!
The rust based cloudflare implementation has C APIs. Also C bindings to rust libs are not that painful at all to maintain.