Matz’s new AOT compiler transforms Ruby source into standalone native binaries via whole-program type inference and C code generation, achieving a geometric mean 11.6x speedup over CRuby miniruby.
Key Takeaways
Pipeline: Prism parses Ruby to AST, spinel_codegen.rb (21,109 lines) runs type inference and emits C, then cc -O2 produces a zero-runtime-dependency native binary.
Self-hosting: the compiler backend is written in the Ruby subset it compiles; bootstrap loop closes when gen2.c == gen3.c after three generations.
Computation wins are dramatic – Conway’s GoL runs 86.7x faster, ackermann 74.8x, mandelbrot 58.1x; real-world workloads like JSON parsing hit 10x, ray tracing 8x.
Small classes (8 or fewer scalar fields, no inheritance) are auto-promoted to C stack structs, eliminating GC overhead entirely; programs using only value types emit no GC runtime.
Hard limitations by design: no eval, no send/method_missing/define_method, no threads – the type system requires a closed-world assumption.
Hacker News Comment Review
The single commenter leads with credibility gating: Matz’s authorship is the key reason to take the closed-world semantics seriously, because a lesser author would likely not handle Ruby’s edge cases correctly.
The comment draws a direct analogy to prior AOT JS work, noting that dynamic input boundaries (JSON.parse, etc.) are the fundamental obstacle – TypeScript adoption has since shifted JS developers toward the type discipline AOT requires, suggesting Ruby’s ecosystem may face the same adoption curve.
Notable Comments
@whizzter: cites own AOT JS compiler thesis; says TypeScript improved JS AOT viability by training developers to restrict input types – implies Ruby type annotations could do the same for Spinel.