Building C Extensions in Ruby
summary
Builds a working Spyglass (OpenCV binding) for Ruby and shows it runs real‑time image code with only the Ruby object wrapper as overhead, details using rake-compiler, ext/ layout and mkmf, and why mkmf often becomes a nuisance. Covers concrete gotchas: memory management (provide mark and free, 99.99% cases avoid complex schemes), testing and gdb attach for debugging, releasing the GVL for concurrency, and API choices like returning self and providing bang methods.
AI-written summary · about
chapters (29)
- 0:00Introduction
- 0:50Aviation
- 2:22Ruby is not slow
- 3:25C is not hard
- 3:45You dont need the whole thing
- 3:57Firstclass citizens
- 4:28Nokogiri
- 4:38Ruby
- 4:59Bundle Gem
- 5:27Ext Folder
- 6:36boilerplate
- 6:55init
- 7:30class
- 8:37see variables
- 9:05say hi
- 9:51checktype
- 10:12enforce classes
- 10:34method parameters
- 10:56function signature
- 11:44string
- 12:07array
- 12:23hashes
- 12:44blocks
- 13:20symbols
- 14:05Define your API
- 14:41Return self
- 15:21Bang methods
- 15:54Questions
- 19:11Garbage Collection








