Compiling Ruby
summary
Shows how Ruby 2.3’s RubyVM::InstructionSequence::load_iseq lets code be compiled to YARV bytecode, stored and reloaded to skip parsing and cut startup time by about 30%. Demonstrates a proof‑of‑concept gem that rewrites source (using the parser gem), performs instruction elimination (e.g. folding 246060 into a literal) and writes/reads .iseq binaries, plus hex‑dumping the ISeq header. Work is intermittent — the custom binary writer is partially functional — but the pipeline and practical gains are reproducible.
AI-written summary · about
chapters (14)
- 0:00Introduction and story
- 2:59Tokenizing and parsing Ruby
- 6:32Instruction sequences in Ruby
- 8:21Compiling to binary format
- 10:05Load ISEQ for faster requires
- 13:23Breaking the compilation process
- 16:15Macros and instruction elimination
- 18:28Modifying the AST
- 21:30Inspecting compiled binary
- 24:03Injecting debugging code
- 25:51Interoperability with Ruby
- 27:17Proof of concept challenges
- 28:42Future of Ruby compilation
- 35:07Q&A on metaprogramming








