3 ms·
Rust wrappers for C libraries work great. C++ is a bit harder, but tooling is getting better. The fact that Rust has zero-cost FFI and even inlining across LLV
by pornel 6y ago
Rust wrappers for C libraries work great. C++ is a bit harder, but tooling is getting better.
The fact that Rust has zero-cost FFI and even inlining across LLVM languages allows you to take existing C/C++ project, and start writing new Rust code on top of it.
It's like a more performant version of what people do with Python. Nobody says "oh, I can't use Python, because my device drivers aren't written in Python".
- ncmncm 6y agoThe better a C++ library is, the less possible it will be to create a Rust wrapper for it. Good C++ libraries depend on language features that are, and will always remain, wholly inaccessible from Rust. Almost every feature of C++ is there to make writing powerful libraries possible. Many uses of such features become part of the library interface, because that enables zero-overhead libraries with semantics intricately integrated into the caller's usage. Rust has a goal of zero-overhead code, but is not designed to minimize the overhead of library usage. That was a choice: it makes the language simpler and easier to learn, but that comes at a cost. You cannot write a Rust library to do what is routinely done in C++ libraries, and a Rust wrapper cannot expose those capabilities to Rust code.