Building a Modern Ruby <-> C++ Toolchain
It started with pybind11 envy. Back in 2020, I used pybind11 to create a Python extension for my company's C++ pattern discovery engine. It took only a few days but enabled our data scientists to make breakthrough discoveries in cancer research. There is something magical when compiled code comes alive in a REPL like IRB.
I wanted that experience in Ruby, but the tooling was not there. Thus began a 5-year journey to build a modern Ruby ↔ C++ toolchain. The result now powers Ruby bindings for libraries such as PyTorch, faiss and OpenCV.
This talk will walk through the toolchain:
- ffi-clang: parse C++ headers using libclang
- ruby-bindgen: generate bindings from the clang AST
- Rice: Ruby <-> C++ interoperability
- CMake: cross-platform native builds
We will cover challenges like ownership, garbage collection, templates and method overloading. Attendees will leave knowing how to bridge Ruby and modern C++ for both small utilities and large, complex libraries.
-
Charlie SavageCharlie Savage is a software architect and long-time Ruby developer with over 20 years of experience. He is the primary maintainer of the Rice Ruby C++ binding library and ruby-prof profiler and a contributor to CMake and ffi-clang. He is Chief Architect at Privateer, building large-scale geospatial and computer-vision systems, and previously founded Zerista which was built on Ruby on Rails.