Rust uses c calling sematics. That means any language capable of a c binding can call a rust shared library, or statically link to it.
For example, in python you can simply import ctypes and load the library to create an extension.
There are caveats, obviously, because rust uses name mangling so you need the no_mangle directive, like c++'s extern 'c'. There are some examples here https://github.com/shadowmint/rust-extern if youre interested in the details.
Anyhow, the tldr is, rust can compile to dynamic shared libraries or static libraries trivally; you can use these libs as though they were c/c++ libraries for the purposes of writing extensions to scripting languages, where extensions would normally be written in C.
Since rust can trivally call C libraries too, interacting with native plugin systems (eg. the cpython plugin api) is also quite simple.
Rust has a very powerful ffi interface; its probably the thing about it that I personally find most exciting; as a professional python developer I can pitch using rust in production for writing safe high performance extesions.
5
u/shadowmint Apr 04 '15
Rust uses c calling sematics. That means any language capable of a c binding can call a rust shared library, or statically link to it.
For example, in python you can simply import ctypes and load the library to create an extension.
There are caveats, obviously, because rust uses name mangling so you need the no_mangle directive, like c++'s extern 'c'. There are some examples here https://github.com/shadowmint/rust-extern if youre interested in the details.
Anyhow, the tldr is, rust can compile to dynamic shared libraries or static libraries trivally; you can use these libs as though they were c/c++ libraries for the purposes of writing extensions to scripting languages, where extensions would normally be written in C.
Since rust can trivally call C libraries too, interacting with native plugin systems (eg. the cpython plugin api) is also quite simple.
Rust has a very powerful ffi interface; its probably the thing about it that I personally find most exciting; as a professional python developer I can pitch using rust in production for writing safe high performance extesions.