Tiny JITs for a Faster FFI | Rails at Scale
15-Feb-2025 40
I love programming in Ruby, and I advocate for people to write as much Ruby as possible. But sometimes you really really must call out to native code. Even in those cases, I encourage people to write as much Ruby as possible, especially because YJIT can optimize Ruby code but not C code.
Taken to its logical extreme, this guidance means that if you want to call a native library, you should write a native extension with a very very limited API where most work is done in Ruby. Any native code would be a very thin wrapper around the function we actually want to call that just converts Ruby types in to the types required by the native function.
Tiny JITs for a Faster FFI | Rails at Scale #ruby #rubydeveloper #rubyonrails #Faster #Rails #Scale https://rubyonrails.ba/link/tiny-jits-for-a-faster-ffi-rails-at-scale