[BioRuby] FFI to Smith/Waterman and Needleman/Wunsh C-extension

Pjotr Prins pjotr.public14 at thebird.nl
Tue Feb 22 22:01:35 UTC 2011


On Tue, Feb 22, 2011 at 03:11:48PM -0500, Chase Miller wrote:
> My understanding is that a C extension ships the source and compiles on gem
> installation, whereas FFI requires multiple pre-compiled shared libraries
> (one for each supported platform) to ship with the gem.  Maintaining all
> those shared libraries sounds like a lot of work.
> 
> I'm not sure I understand why FFI is preferred; could someone explain it a
> little more in detail?

For the C ext you have to learn the Ruby C API. It is C.

FFI allows you to define a C mapping in Ruby. You don't even have to
write C code.

That is the difference.

The first option is what Rext does for R, and XS does for Perl. The
second is more like generating C bindings, something SWIG does too. 

Your mileage may vary, but I am glad we can get away from that. Note
that when Rext, XS or Ruby C API changes, there may be a lot of work
involved (like between Perl 5 and 6). FFI mappings are more portable,
also between (future) versions of Ruby, as they *generate* code.

Hope that helps. But there is no reason not to dig a little. Nothing
replaces experience...

Pj.



More information about the BioRuby mailing list