Experimental work from Mojo core contributor Evan Ovadia introduced a technique to pass generic data types and functions between Rust and other programming languages, bypassing the limitations of the traditional C Application Binary Interface (ABI).
Ditching the C ABI for Cross-Language Generics
Programming language generics usually cannot ride across the traditional C ABI because C itself lacks the concept of placeholders for data types to be provided later. When developers want to use a library from one compiled language in another, they typically rely on the C ABI as a de facto interoperability layer. Rust libraries can expose functions using extern "C" and data structures marked with repr(C), allowing access via a Foreign Function Interface (FFI).
However, this conventional approach strips away rich type information, reducing complex data down to primitive values and raw pointers. Evan Ovadia, a former Google engineer building the experimental Valen programming language—an offshoot of an earlier project named Vale—encountered this exact roadblock. He wanted Valen programs to leverage existing Rust libraries, notably the wgpu graphics library, without manually wrapping every single interface.
Because Rust heavily utilizes generics across its library ecosystem, and Valen relies on them too, the C ABI boundary proved entirely inadequate. As Ovadia noted in his explanatory blog post, the core mystery to solve was simple to state but brutally hard to execute: how do we achieve cross-language generics?
Driving the ‘Golden Spike’ Between Compilers
To solve the challenge of cross-language generics, Ovadia designed a two-part architectural bridge inspired by the final spike hammered into the United States’ first transcontinental railroad line. Instead of reducing rich libraries into raw primitives to fit into coarse C ABI wagons, his method lets two independent compilers collaborate directly.
First, Valen runs the Rust compiler directly as a library by embedding rustc_driver into its own memory space. This eliminates the need to invoke a separate command-line process for compilation operations. Second, Ovadia patched the Rust compiler so that it can recognize non-Rust Valen types. When the Rust compiler encounters a Valen type, it hands control over to the Valen compiler, pauses, and waits for the compiled result.
This bidirectional setup allows Valen to call generic Rust functions while simultaneously enabling Rust to call back into Valen for required values or types. The arrangement creates an interactive dynamic entirely foreign to conventional FFI wrappers, which require rigid, fixed interfaces before execution.
The Maintenance Cost of Intrusive Compiler Patching
While the approach successfully bridges the gap, it comes with notable technical debt. Ovadia freely admitted that patching the Rust compiler was the “nuclear option” and the riskiest part of the entire endeavor. The patch itself is relatively compact at around 100 lines of code, but it is inherently hacky and assumes that Rust is utilizing LLVM for machine code generation.
“It works, but it’s definitely not upstreamable,” Ovadia explained regarding the patch.
Because Rust does not offer stability guarantees for its own internal compiler components, relying on compiler internals as an interoperability surface exposes a project to high maintenance overhead whenever the upstream Rust compiler updates.
Ecosystem Reception and Future Outlook
The experiment sparked intense technical discussions across programmer forums such as Reddit and Lobste.rs. Observers praised the sheer ambition of tackling such a complex systems programming problem, even as they scrutinized the fragile details of compiler-level coupling.
“I appreciate the move to replace C as the ‘universal FFI language,'” one community commenter wrote, highlighting the boldness of the choice.
Another reader pointed out potential type system limitations, suggesting that building bindings on top of languages like Ada could yield similarly fascinating architectural explorations. For now, Ovadia remains heavily focused on developing Valen. Yet, by proving that Rust can be turned into a library that other languages build from, the “Golden Spike” opens a viable path toward bootstrapping new language ecosystems without relying on the creaky, restrictive C ABI.