• No need to write wrapper routines in C/C++
  • No need to know how to write C/C++ code to leverage existing C/C++ code. One just has to undestand the essential concepts of the C/C++ data structures, pointers to them and memory allocation.
  • Code is simpler to write, read and maintain as there is no C code.
  • Can rapidly invoke a native routine and create and populate data structures from any foreign/native DLL/DSO.
  • Can rapidly prototype using native code.
  • All of these mean that we can avoid distracting details of writing, compiling, linking and loading code to leverage native libraries.
  • We do not need to have development libraries installed, but just the run-time libraries.
    To generate the interfaces programmatically (via the RGCCTUFFI package) one does need the header files. But for manual construction of the call interface (CIF) objects, there is no compiling or linking and so we don't need the development libaries agains which we would link.
  • Cons

  • Minimal type checking as values are passed from R to native code.
  • Code we write may not be portable as data structures may be different on different platforms. This applies to any C code we might write as well and so is not really a reason against using FFI. However, there will be no error checking performed which would occur when compiling C code.

  • Duncan Temple Lang <duncan@wald.ucdavis.edu>
    Last modified: Mon Feb 14 10:48:18 PST 2011