3 ms·
But that's also the brilliance of Rust supporting a clean C ABI. I can write in anything I want since every language supports C ABI for system calls. I don't
by vvanders 9y ago
But that's also the brilliance of Rust supporting a clean C ABI.
I can write in anything I want since every language supports C ABI for system calls.
I don't want to have to learn a whole new language and new API at the same time.
Also a cursory glance at Julia's numpy support looks like it requires deep copies which is painful when you want things to be fast.
I'm sure it's a great language but needing to drag in a whole new VM means it doesn't fit my needs.
- gravypod 9y agoJulia is jit compiled by llvm to your native machine code. Correctly written Julia is within 1.5 the speed of C. It removes the complexity of needing to do the FFI at all.
- deleted 9y ago[deleted]
- vvanders 9y agoYou make it sound like ffi is a nasty 3 letter word ;). It look me 3 lines of code to import the dll, assign the signature and call the function, I'd hardly call that complex.
- mlevental 9y agothis is probably a dumb question but did you just compile the rust binary and then expose the functions? how? I don't remember but does rust face header files?
- vvanders 9y agoYup, just declare the function like so: #[no_mangle] pub unsafe extern "C" fn transform_pcm( data: *mut c_short, len: c_uint, ramp_time: c_uint, tone_delta_frame: c_float) { then call from python: gen_pcm_dll = ctypes.cdll.LoadLibrary("gen_pcm_rust/target/release/gen_pcm.dll") gen_pcm_dll.transform_pcm.argtypes = [ctypes.c_void_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_float] gen_pcm_dll.transform_pcm(ptr, len(pcm), ramp_time, tone_delta_frame) Rust doesn't generate headers(although there are helper libs if you want) and you don't need them to FFI.
- the_mitsuhiko 9y agoHere is how we do it: https://blog.sentry.io/2017/11/14/evolving-our-rust-with-milksnake https://blog.sentry.io/2017/11/14/evolving-our-rust-with-mil...