From: Arne K. <arn...@iw...> - 2011-08-18 15:59:23
|
Hello, I started writing Lisp bindings for a C library with CFFI, but I'm not sure that this is the best way to go, or if I should use SBCL FFI instead. I couldn't find any good information about the advantages and disadvantages of CFFI compared to the SBCL FFI (except that these are limited to SBCL of course, but this isn't a problem for my use-case). Is there any recommendation which one to use? Is maybe one of them (probably SBCL FFI) only kept for backward compatibility and its use not recommended for new projects? I'd be very glad about any help on this topic. Thank you, Arne |
From: Teemu L. <tli...@ik...> - 2011-08-18 16:59:56
|
* 2011-08-18T17:36:00+02:00 * Arne Klein wrote: > Is there any recommendation which one to use? Yes, here's mine: use CFFI because then you write higher-level code. It abstracts away implementation-specific code. Common language for all Common Lisp programmers is good. Scattered communities is bad. |
From: Stas B. <sta...@gm...> - 2011-08-18 17:05:04
|
Arne Klein <arn...@iw...> writes: > Hello, > > I started writing Lisp bindings for a C library with CFFI, but I'm not > sure that this is the best way to go, or if I should use SBCL FFI > instead. I couldn't find any good information about the advantages and > disadvantages of CFFI compared to the SBCL FFI (except that these are > limited to SBCL of course, but this isn't a problem for my use-case). > > Is there any recommendation which one to use? Is maybe one of them > (probably SBCL FFI) only kept for backward compatibility and its use > not recommended for new projects? I'd be very glad about any help on > this topic. CFFI uses SBCL's FFI. CFFI is a compatibility layer for FFIs across different implementations. So, if you choose to use SBCL's FFI, your code will run only on SBCL, while when using CFFI it will be portable among other implementations. -- With best regards, Stas. |
From: Paul K. <pv...@pv...> - 2011-08-18 17:33:52
|
In article <87p...@mi...da>, Teemu Likonen <tli...@ik...> wrote: > * 2011-08-18T17:36:00+02:00 * Arne Klein wrote: > > > Is there any recommendation which one to use? > > Yes, here's mine: use CFFI because then you write higher-level code. It > abstracts away implementation-specific code. Common language for all > Common Lisp programmers is good. Scattered communities is bad. I'm all for portable code, but it is patently false to assert that smoothing over difference in systems until convergence to a common subset of features leads to a higher-level interface. If anything, it clearly has the opposite effect. There are multiple meanings to the word "abstract", and some programmers seem to harmfully conflate them, sometimes in the same sentence. There are fewer SB-ALIEN users, and parts of it can be obscure. That's a good reason to use CFFI, even if you're not worried about using other implementations. On the other hand, SB-ALIEN hooks usefully in SBCL's type system, giving you more, more useful, diagnoses and warnings at compile-time. Paul Khuong |