# Integrating Julia with Rust?

**URL:** <https://discourse.julialang.org/t/integrating-julia-with-rust/121745>\
**Category:** General Usage\
**Created:** [October 25, 2024, 11:12am UTC](https://discourse.julialang.org/t/integrating-julia-with-rust/121745 "2024-10-25T11:12:04Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 25, 2024, 1:22pm UTC](https://discourse.julialang.org/t/integrating-julia-with-rust/121745/3 "2024-10-25T13:22:05Z")

</div>

It is possible to call Rust (dynamic) libraries from Julia, with `ccall` keyword. It implies C-like API of your Rust code used (or Fortran, or C++, or well C) used.

I.e. you need to add `extern "C"` to functions you call (and possibly also use `#[repr(C)]`, i.e. for Rust structs, but I think you don’t need to do that always, even never, i.e. if they are not involved in interop).

[https://docs.rust-embedded.org/book/interoperability/c-with-rust.html](https://docs.rust-embedded.org/book/interoperability/c-with-rust.html)

I believe e.g. this is an example of that Polars.jl.

It IS also possible to call Rust from Julia (at least up to 1.10 LTS and 1.11), i.e. embed Julia in Rust, with a package for that, like you can embed Julia into Python, R etc.

I believe in the developer since the package (that I haven’t used) seems very well documented and well received, and has supported across many Julia versions with it’s “unstable C API”.

E.g. the internal C [non-]API of Julia was broken with 1.11, why `juliacall` for R is in a bit of trouble with a trivial fix though.

The package for Rust is not in trouble, I see it was fixed for 1.11, and is tested for it:

> Array functions that have been removed in Julia 1.11, like `jl_reshape_array`, have been removed completely. Call the Julia function instead.

I wouldn’t worry about being able to call Julia from Rust, since you can stay with 1.10 LTS version, that was very recently declared, and thus will be supported for (I assume) the next 3+ years. If 1.12+ breaks something I’m confident it will be fixed in interop packages, but if you’re really worried about maintainers going missing then you have at least 1.10 and 1.11 to call, and Rust is a very important language that I’m sure someone would take over.

I note it’s not yet possible to call Python 3.13 from Julia (nor call from it likely), I filed an issue, it seems Python might have broken its API, or if not PythonCall.jl relied on internals. Python does have a stable API (also another level limited API, then internals, unstable, and they are changing unusually many now).

See also:

> [@Is Rust (and/or Python) the new high-level API (here ANN/GGUF/LLama example)](https://discourse.julialang.org/t/is-rust-and-or-python-the-new-high-level-api-here-ann-gguf-llama-example/121721):
>
> This state-of-the-art library has Rust and Python API, but ironically no (C++) high-level one despite written in C++: I’m guessing C-like C++ is kinda necessary for bindings to other [languages] [TensorFlow, also written in C++, only had officially stable Python API (while Julia’s API better until unmaintained).] If we want to call this library then we can for sure, using PythonCall.jl, also an option to call Rust’s API. So which would you prefer? You might think why not use: GGUF mod…

---

_[View the full topic](https://discourse.julialang.org/t/integrating-julia-with-rust/121745)._
