I have some unstructured opinions on this topic.
I’ve worked on a number of small projects in this space and as part of them I’ve had various discussions with people about the best way to go about the process of making bindings available in a target language. If I were to generalize, people prefer writing bindings in the language that they are most comfortable with. For interfaces in Python, a C++ developer would prefer pybind11, a C developer might prefer SWIG, a Python developer would prefer cffi + extern C ABI.
To target Julia, a Rust developer would prefer writing pure Rust (the pyo3 equivalent to Julia in Rust). A Julia developer would prefer writing Julia and currently has to write unsafe Rust code.
For a Rust developer, currently jlrs
seems like the best way to make a Julia package. First class support for this workflow would help make it easier for those in the Rust community to seamlessly support Julia. This would involve projects that show that this is a viable, templates for getting started, best practices, making it trivially easy to build _jll
s, publish them on Yggdrasil, register a package on the official registry etc. (Using jlrs
would require making a _jll
and then making a package on the General Registry, right? In Rust, if I’m able to build something locally, I can run cargo publish
and it’ll become available on crates.io in minutes. cargo
allows extensions. Would it be possible to make a cargo julia-publish
? Do we need a unofficial alternate registry for crates that are also julia source code + _jll
s?)
For a Julia developer, faster iteration of building _jll
for the extern C ABI in Rust might help? When I was building Crossterm.jl
, if I had to fix a bug that crossed the ABI, I had to make a change to libcrossterm
, push a change to Yggdrasil, wait till it was merged, wait till it was registered, then update the dependency locally to test it in Julia. I set up a BinaryBuilder action on GitHub to help but having a faster way to iterate locally would have helped significantly. (If I wanted to use the Rust crate directly, I had to change Julia source code to point to the local shared library and testing this on Windows, MacOS, Linux was a pain. It was easier for me to register it and wait to test it later.)
For a Julia developer, writing unsafe extern C interfaces in Rust and exposing them to Julia also requires dealing with how to handle errors (do you pass in an error object over the C ABI? Set a global variable in Rust? How to translate a panic in Rust to a Julia exception? How to handle errors in a separate thread in Rust?) and ownership (should Rust be the owner or pass back ownership to Julia? what’s the best way to handle multiple references to the same object? Can we use Julia’s GC to clean up Rust objects?). Having guidance on this will make it easier for a motivated Julia developer to dive into Rust and figure out the interconnection.
All that said, I want to say that I’m certainly not suggesting this is a big problem that needs a solution immediately. Python has a much large community of users, and has naturally evolved solutions like swig, pybind11, cffi, pyo3, nimpy etc over time. I think if we can identify low hanging fruit and tackle those problems, we’ll be able to decrease the friction a little. But without a “automagical” solution that makes Rust code “just work” in Julia, I think there’s only so much that we can practically do.