4 ms·
I got this impression as well. It seems like Rust would have been a great fit for what he/she is looking for. For example, calling into Rust from Python is dead
by thinkpad20 11y ago
I got this impression as well. It seems like Rust would have been a great fit for what he/she is looking for. For example, calling into Rust from Python is dead simple because of its C-compatible ABI.
- Ygg2 11y agoRust doesn't have stable ABI. I think what you meant is that Rust exposes C API.
- thinkpad20 11y agoHmm, I guess I'm not familiar enough with the terms to be confident that I'm using the correct terminology, but in any case it's very easy to call Rust code from C, or from Python, etc. Anything that can call C code can call Rust code (with a few compiler directives around the desired functions to prevent name mangling etc). This might not be the exact same thing as having the same ABI (although I had been under the impression that that is what it meant). Examples: http://blog.rust-lang.org/2015/04/24/Rust-Once-Run-Everywhere.html http://blog.rust-lang.org/2015/04/24/Rust-Once-Run-Everywher... https://gist.github.com/seanjensengrey/f5d73bbdf22cfa1ad463 https://gist.github.com/seanjensengrey/f5d73bbdf22cfa1ad463
- tatterdemalion 11y ago"Rust's ABI" is the representation of functions without `extern` declarations. `extern` causes functions to use a different ABI, by default `extern "C"`. https://doc.rust-lang.org/reference.html#extern-functions https://doc.rust-lang.org/reference.html#extern-functions
- eridius 11y agoIt's not that Rust has a C API, it's that Rust has a simple means by which you can mark a function as using the C calling convention, and export this function as a symbol from your library, which lets anything else that speaks the C calling convention (e.g. C, or plenty of other languages) invoke that function.
- Ygg2 11y agoYeah, I did say exposes C API. It's what most crates that have it, call it.
- eridius 11y agoSaying that a particular crate has a C API makes sense. Saying that Rust has a C API suggests that Rust has some equivalent to e.g. Python or Ruby's C APIs that let you invoke arbitrary Rust code from C, which isn't true.