Comment by Aurornis

4 hours ago

> What I find particularly ironic is that the title make it feel like Rust gives a 5x performance improvement when it actually slows thing down.

Rust didn't slow them down. The inefficient design of the external library did.

Calling into C libraries from Rust is extremely easy. It takes some work to create a safer wrapper around C libraries, but it's been done for many popular libraries.

This is the first and only time I've seen an external library connected via a Rube Goldberg like contraption with protobufs in the middle. That's the problem.

Sadly they went with the "rewrite to Rust" meme in the headline for more clickability.

> Calling into C libraries from Rust is extremely easy

Calling the C function is not the problem here. It is dealing with the big data structure this function returns in a Rust-friendly manner.

This is something Protobuf does very well, at the cost of performance.

  • Writing Rust bindings for arbitrary C data structures is not hard. You just need to make sure every part of your safe Rust API code upholds the necessary invariants. (Sometimes that's non-trivial, but a little thinking will always yield a solution: if C code can do it, then it can be done, and if it can be done, then it can be done in Rust.)