From C extension to pure C: Migrating RBS
summary
RBS moves from a Ruby gem with a C extension to a pure C library that exposes a C API so tools like Sorbet (C++) and JRuby can use RBS without loading the Ruby VM. Work replaces RB_raise exceptions with bool-return error handling and out-parameters, and replaces malloc/free patterns with an arena allocator to avoid leaks and simplify early returns. Result: removes the Sorbet runtime dependency, enables multi-threaded parsing (Sorbet already type checks ~9M lines under a minute), and has an open PR and internal Shopify experiments.
AI-written summary · about
chapters (10)
- 0:00Introduction and speaker intro
- 1:07What is RBS and why it matters
- 3:54RBS vs Sorbet sig syntax
- 7:00Why migrate RBS to pure C
- 10:12Ruby VM conveniences in C
- 11:56Error handling without exceptions
- 15:26Memory management challenges
- 21:49Arena allocators for cleanup
- 27:18Benefits of pure C libraries
- 28:20Summary and call to action
related talks
22mStatic typing with RBS in Ruby
30mIntroducing Sorbet into your Ruby codebase
28mMaking the RBS Parser Faster
33mAdopting Sorbet at Scale
30mCompiling Ruby to Native Code with Sorbet & LLVM
32mThe State of Ruby 3 Typing
30mSorbet at Grailed: Typing a Large Rails Codebase to Ship with...
30mFrom Ruby 2 to 4: Updating a C extension for a Modern VM
