DevOps
Ruby inventor Matz working on native compiler with AI help
Matz gets together with Anthropic's Claude to create an experimental ahead-of-time compiler for Ruby – though with many limitations
Yukihiro Matsumoto - better known as Matz - is building Spinel, a native compiler for Ruby, with help from Anthropic's Claude Code.
Spinel, which is on GitHub under the MIT license, works by parsing Ruby code into AST (abstract syntax tree) files, then converting it to C code for compilation by a standard C compiler. In Matz’s tests, Spinel-compiled code runs approximately 11.6 times faster than MiniRuby - a stripped-down Ruby build - using the in-development Roby 4.1.0.
The output is C code, compilable to a native executable via gcc (GNU Compiler Collection) on Linux or Windows (with MinGW - Minimalist GNU for Windows), or via LLVM's Clang on Linux or macOS. BSD will "probably work", according to the readme, but is not tested.
Ruby is an interpreted language, meaning it depends on a runtime engine to parse and run the code. In order to improve performance, Ruby can use just-in-time (JIT) compilers including MJIT (method-based JIT), YJIT and ZJIT, with the latter two developed by Shopify, a prominent Ruby user. Spinel is different in that it generates standalone native code executables, which can be deployed without any additional runtime.
The downside of Spinel is that it supports only a subset of Ruby. Unsupported features include eval statements, which evaluate and execute Ruby code at runtime, threads, text encoding other than UTF-8, metaprogramming such as defining a method at runtime, and deeply nested lambda functions.
Ruby variables are not typed, though objects are strongly typed. Spinel performs type inference to enable C code generation, since C is a strongly typed language. The code makes use of an existing and mature Ruby parser called Prism. There are many optimizations, such as method inlining and dead code elimination, and the generated C compiles cleanly at the default warning level. Spinel includes a garbage collector, to reclaim memory automatically, and supports FFI (foreign function interface) for integrating with native code libraries such as libc or SQLite.
Spinel is experimental and will not work with most existing Ruby code, including the web application framework Ruby on Rails. But it is possible for Ruby developers to write code with Spinel in mind, such as for helper functions that can then be called from other Ruby code, as a means of optimization.
MORE CONTEXT
-
Bun posts Rust porting guide, says rewrite is still half-baked
-
Cloudflare experiment ports most of Next.js API 'in one week' with AI
-
Anthropic tests how devs react to yanking Claude Code from Pro plan
-
Brit mathematician lets AI agent loose with credit card – cue password leaks, CAPTCHA chaos and more
Matz presented Spinel at RubyKaigi 2026, a conference in Hakodate, Japan last month. According to attendees such as this one (original text in Japanese) Matz said the idea for Spinel was conceived three years ago, but has now been implemented in a few weeks using AI.
Most of the code in the Spinel repository is headed with a comment including "co-authored by: Claude Open 4.7 (1M context)."
Further, the project has already been rebuilt three times over, in a series of experiments.
Matz, perhaps, is an ideal user of AI-generated code. He understands the code, and can benefit from the increased speed of development without losing grip on what the code does, and is able to refine it with his existing skills as well as with further AI prompting, and the code is covered by hundreds of tests and benchmarks. ®




