These are chat archives for rust-lang/rust

13th
May 2016
Scott P. Jones
@ScottPJones
May 13 2016 11:56
Hi! Somebody asked me about calling into Rust from Julia (Julia can call any C function that’s in a shared library / dll directly). Has anybody here dealt with that, or the ease of building a shared library out of Rust code, to be called from other languages using C ABI?
Erik Hedvall
@Ogeon
May 13 2016 12:00
That's indeed possible and not particularly hard, as far as I know. Here's the section of The Book where you can read some more about exposing functions: https://doc.rust-lang.org/book/ffi.html#calling-rust-code-from-c
Scott P. Jones
@ScottPJones
May 13 2016 12:05
Thanks!
Somebody suggested that I look at Rust, to replace the parts where now I’d drop back to my old standby, C (most everything I can do quite efficiently in Julia, however at times the GC gets in my way, and bit twiddling is harder than in C at times)
Erik Hedvall
@Ogeon
May 13 2016 12:14
Rust will probably work just as well for those tasks, although you will most likely have to do some translation to and from safe datatypes (especially for heap allocated types), but it's not much of a problem.
Scott P. Jones
@ScottPJones
May 13 2016 14:09
What I was hoping for, is to be able to pass pointers to Julia allocated arrays/vectors (so they are GCed by Julia), and process them quickly in Rust (and any temp allocations being done in Rust, nice and quick, instead of making the GC churn later on in Julia)
Erik Hedvall
@Ogeon
May 13 2016 16:45
It shouldn't be a problem as long as you can replicate the data types in Rust. I know basically nothing about Julia, so I can't say if it will be problematic in any other way.
LeonineKing1199
@LeonineKing1199
May 13 2016 19:37
Does that fix Scala's difficulty in implementing FP in an environment that's anti-FP? If you still have to worry about trampolining, it didn't do much...