Re:Why I'm Choosing C++
by thinkpad20 on Monday February 01, 2016 @12:57AM
(#11010053)
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.
[ Parent
| on HN ]
Rust doesn't have stable ABI. I think what you meant is that Rust exposes C API.
It'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.
Yeah, I did say exposes C API. It's what most crates that have it, call it.
Saying 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.
Re:Why I'm Choosing C++
by thinkpad20 on Monday February 01, 2016 @01:06AM
(#11010080)
Hmm, 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-Everywher...
Re:Why I'm Choosing C++
by tatterdemalion on Monday February 01, 2016 @01:30AM
(#11010144)
"Rust's ABI" is the representation of functions without `extern` declarations. `extern` causes functions to use a different ABI, by default `extern "C"`.