What are the tr开发者_JS百科ade offs between ffi and mri c extensions in ruby?
One obvious tradeoff is that MRI C extensions only work on MRI, whereas FFI extensions work on MRI, YARV, Rubinius and JRuby at the moment, and will in the future probably also work on IronRuby, MagLev, MacRuby, SmallRuby, tinyrb and RubyGoLightly.
ffi is a tidge slower for method call invocation. Also ffi can't use any "native C" code unless you combine it with compilation, for example with ffi-inliner.
ffi is much more cross-VM friendly.
精彩评论