Programming language designer Evan Ovadia has shown a way for another language to pass data and functions to and from Rust while keeping full type information, including Rust's generics, DevClass reported Saturday. He calls the technique the Golden Spike and built it for Valen, a new language he is developing.

What Happened

Ovadia, a former Google engineer and core contributor to the Mojo language, writes about language design on his blog, verdagon.dev. Valen is an offshoot of his earlier language, Vale, and he pitches it as a faster, more developer-friendly take on Rust.

The Golden Spike name refers to the final spike driven into the first transcontinental railroad line in the United States, which joined two separately built tracks into one route.

RelatedClaude Code Desktop Preview Flaw Could Have Exposed Developers’ Cloud Keys, Researchers Say

The method has two parts. First, it uses rustc_driver, an existing interface that lets a program run the Rust compiler as a library, so Valen embeds rustc directly in its own process. Second, Ovadia patched the Rust compiler so that when it runs into types that are not Rust types, it hands control to the Valen compiler to compile that portion and waits for the result. That lets a single generic function mix types from both languages.

The patch is only about 100 lines of code. Ovadia described it as the riskiest part of the project and acknowledged it is hacky. It assumes Rust is using LLVM to generate machine code, which is not always true, and he said that while it works, it is "definitely not upstreamable."

The host of the Let's Get Rusty YouTube channel called the work the most fascinating thing he had read in months.

Why It Matters

Most cross-language calls to Rust go through the C application binary interface, the lowest common denominator that nearly every language can speak. C has no concept of generics, so the C ABI cannot describe them either. That is a real barrier for Rust, whose libraries use generics heavily. Rust compiles a generic function separately for each concrete type it is used with, so there is no single precompiled version that another language could simply link against.

In practice, that means developers write wrapper code that fixes generic functions to specific types before exposing them, and lose much of a library's flexibility in the process. Tools such as bindgen and cxx reduce the work for C and C++, but they do not remove the underlying limit.

For a new language, access to Rust's large ecosystem of crates without that wrapper layer would be a significant advantage. Libraries for networking, serialization, cryptography and data processing could be used as they are, instead of being rewritten or wrapped by hand.

The Limits

The dependence on LLVM matters because Rust has other code-generation backends, including Cranelift and a GCC-based backend, that the patch would not cover. And because the change is not suitable for the official Rust compiler, anyone using it would need to maintain a patched toolchain and keep it in step with Rust's regular releases.

What to Watch

The technique is experimental. Watch whether Ovadia or others find a less invasive way to achieve the same handoff that the Rust project could accept, whether the approach is extended beyond LLVM, and whether other language projects adopt the idea to gain direct access to Rust libraries.