Compiling Ruby
summary
Shows how Ruby 2.3’s RubyVM::InstructionSequence::load_iseq lets compiled YARV bytecode be saved, reloaded and substituted for source, and demonstrates actual tools: Bootsnap’s loader, the parser gem for AST rewrites, a Vernacular gem that injects lexical macros, and a Tuby prototype that emits bytecode and sometimes works. Claims include performance wins from instruction elimination, practical uses in tests, and brittle dependency on Ruby’s binary dump format.
AI-written summary · about
chapters (15)
- 0:00Compiling Ruby
- 1:22Ruby execution process
- 1:54Tokenizing the input
- 5:08Building YARV instruction sequences
- 6:16Executing YARV instruction sequences
- 7:00Reading/writing YARV instruction sequences Ruby 2.3
- 9:10Programmatically loading YARV instruction sequences
- 12:04Examples
- 12:47Now for the fun part
- 18:26Let's go further
- 21:37Let's go even further
- 23:19We can inject debugging code into Ruby to learn the binary structure of a YARV bytecode dump.
- 28:21Why would you ever do this?
- 28:40Code gets read many more times than it gets written.
- 30:30What's next?
related talks
40mCompiling Ruby
29mA Rails Developer’s Guide To The Ruby VM
34mCompiling Ruby scripts
33mRuby the Hard Way: Writing Bytecode to Optimize Plain Ruby
38mPrecompiling Ruby scripts - Myth and Fact
36mSome Assembly Required
39mInside Ruby's VM: The TMI Edition.
38mRubyX: Compiling Ruby and it's effect on the community
