Rust integration / interop / compilation target?

I am encountering a whole lot of Rust code lately. I probably don’t have to tell you how successfully Rust has grown in popularity and utility. It also seems to me that people who are interested in Kotlin overlap a lot with people interested in Rust. (Despite that it seems Rust and Kotlin core teams do not seem very interested in each other.) I don’t think Rust is just another potential target. I think, for social reasons, Rust could be a strategic co-evolving ecosystem, and I would like to open this thread for considering ways that Kotlin could integrate or interoperate with Rust, including utilizing crates, transpilation, packaging Kotlin code as a crate, or anything else a dev might want to do when code is written and they want to use both. Anything exist already? Perhaps my perception is wrong?

It’d be really difficult considering that Kotlin is a garbage-collected language. Kotlin already has C interop, so Rust can use that, but otherwise Kotlin has no concept of lifetimes, or Rust traits

1 Like

Hi! There was a talk on this topic at KotlinConf. I didn’t watch it, so I can’t you much more than that. You may want to subscribe to, they should publish the talks sometimes this month.

As mentioned by @clovisai there was a talk recently on this at Kotlinconf, it’s main focus was on a tool written by Mozilla that allows the interop but to summarize the tool does bindings with C and works as a middle man… something like: Kotlin ↔ C Bindings ↔ Rust.

This is the talk and speaker: Link

The tool is called Uniffi: Uniffi and is tool for binding rust to multiple languages. The kotlin KMP is: GitHub

I think is interesting as an idea but overall seems to bring more problems than solutions.