Golden Spike: Connecting Valen to Rust Without C ABI for Cross-Language Generics
Evan Ovadia, creator of the Valen language, develops a "Golden Spike" plan to enable direct cross-language generics between Valen and Rust by embedding rustc as a library and patching the Rust compiler to hand off non-Rust types to the Valen compiler, bypassing C ABI limitations.
Finally Abandoning C ABI
Evan Ovadia, a former Google engineer and core contributor to Mojo, is developing Valen (a fork of the earlier Vale language) as a faster, more developer-friendly alternative to Rust. He wants to leverage Rust's excellent libraries, especially its graphics libraries, from Valen. The conventional way to use libraries across languages is through the C ABI (Application Binary Interface), which defines conventions for passing data and function calls between compiled code. Rust can expose functions via extern "C" and types via repr(C) for access via FFI (Foreign Function Interface). However, the C ABI has no concept of generics because C itself lacks generics, while both Rust and Valen rely heavily on generics. Ovadia frames the core puzzle: "How do we achieve cross-language generics?"
Cross-Language Generics Finally Emerge
Making two compilers cooperate is tricky because compilers are typically isolated. Ovadia needed Valen to call Rust generic functions and also have Rust generic functions call back into Valen for required values. After extensive iteration, he devised a two-step solution:
Run the Rust compiler as a library. Rust already supports this via rustc_driver, allowing Valen to embed rustc directly in its own memory space.
Patch the Rust compiler to yield control to the Valen compiler when it encounters a non-Rust Valen type, then wait for the compilation result.
Ovadia admits patching rustc is the "nuclear option" and the highest-risk part. The patch is only about 100 lines of code but is rough, assumes Rust uses LLVM for code generation (which is not always true), and "definitely cannot be merged upstream."
Despite the roughness, this bidirectional cross-language generics mechanism represents a significant step forward in programming language interoperability. Ovadia is now fully focused on the Valen project, but his work opens the possibility for new languages to build on Rust libraries with only minor modifications to Rust itself, potentially making the decades-old C ABI dependency a thing of the past.
On Reddit and Lobste.rs, observers praised Ovadia for solving a hard problem while expressing concerns about the details. One user noted: "I appreciate the effort to replace C as the 'universal FFI language.' This is a very bold choice." Another questioned whether Rust's type system limitations make it an ideal interoperability language, humorously adding: "Imagine if you could make ski bindings in Ada!" The host of the Let's Get Rusty YouTube channel called the work "the most fascinating thing I've read in months" and dubbed it "Rust++." Ovadia's own blog post compares the effort to the "Golden Spike" — the final spike driven into the first US transcontinental railroad — symbolizing a sturdy high-speed rail replacing the rough freight cars of C ABI.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
