Pre-evaluation in Ruby
summary
Describes a gem called Preval that parses source with Ripper AST transforms, visits and rewrites nodes (constant-folding, integer arithmetic, attr_reader/attr_writer expansion, loop simplifications), and writes the rewritten code back into Ruby via a Bootsnap compile-time hook. Changes are opt-in per visitor, happen at compile/startup so there is zero runtime overhead, and a production trial briefly deploys it (no measurable perf win there) but the tool works as a style and compile-time optimizer.
AI-written summary · about
chapters (9)
- 0:00Start
- 0:56Warning
- 1:33Compilers
- 2:10Lexical Analysis
- 3:21Semantic Analysis
- 6:09Instruction Generation
- 8:37Optimization
- 16:38Demo
- 28:20Test code
related talks
45mUsing Ruby to Generate Faster Ruby Code through Partial Evaluation
25mCrash course in transpiling Ruby
33mRuby the Hard Way: Writing Bytecode to Optimize Plain Ruby
29mHow to Load 1m Lines of Ruby in 5s
32mParsing Ruby
51mOpening Day 3 Keynote
43mGrammars, Parsers, and Interpreters, In Ruby
38mPrecompiling Ruby scripts - Myth and Fact
