An experiment is afoot to sidestep C as the language of interoperability with Rust.
Programming language generics can now ride in style from one language’s compiler to another and back again, thanks to experimental work from Mojo core contributor Evan Ovadia.
“Technically, this is the most fascinating thing I’ve read in months,” enthused the host of the Let’s Get Rusty YouTube channel, explaining the work, which he characterized as “Rust++.”
Ovadia describes his work in an explanatory blog post as the “ Golden Spike ” that intertwines two different languages, referring to the final spike affected into the United States’ first transcontinental railroad line.
The work came about in Ovadia’s effort to create his own language, Valen more dev-friendly version of Rust.
The problem with creating a new language from scratch, he reasoned, was that he couldn’t use his favorite Rust libraries.
With the C ABI, if a Rust library exposes its functions as extern "C" and exposes its types as repr(C), then they can be accessed from another language using a Foreign Function Interface (FFI).
After much rumination, Ovadia arrived at a two-part solution to cross-language generics: first, run the Rust compiler as a library. The second step would be to patch Rust so that when it encounters non-Rust Valen types, it hands control over to the Valen compiler to handle its portion, and waits for the compiled result.
Ovadia has his hands full with Valen at this point, though his cross-language generics work opens the possibility of using Rust to bootstrap other new languages that can be built from Rust libraries.