----- Original Message ----- From: "Robert H" <sigz...@gmail.com>
To: <inline@perl.org>
Sent: Wednesday, September 16, 2009 11:28 AM
Subject: XS vc Inline


When would you not use Inline instead of doing it with XS? For example, I am thinking about doing a wrapper for Metakit (ie DBD::Metakit). I talked with the author of Metakit and he said he tried to do a Perl wrapper in XS once but got lost. Is it feasible to do something like that using Inline instead or would XS be the best case scenario for a DBD module?

Both approaches are feasible - Inline::C is, after all, just a means of auto-generating an XS file. It does a little more than that, of course - it also compiles the XS code it created, and then runs the script (which usually makes use of that XS code).

The tricky bit (and this may well be where the author "got lost") is often in the way the Perl API meets the library that you want to wrap, and you face the same challenges in that regard whether it's an Inline::C script or an XS file that you're trying to write.

For modules, I have a preference for XS, rather than Inline::C - but I don't have any really compelling reasons for that preference. I think there might still be issues if one Inline::C module tries to use another Inline::C module (not sure) .... and I like to keep pre-requisites to a minimum .... and XS just seems cleaner to me for modules .... but, as I said, nothing compelling.

Inline::C does provide a nice "test it as-you-go" facility, so if you think that might make the task easier, by all means do it in Inline::C. When it's all done, if you want, you can convert your Inline::C code to XS code by running it through InlineX::C2XS (which uses Inline::C to autogenerate the XS code from your Inline::C code). InlineX::C2XS will also write a Makefile.PL and stub pm file for you if you want. (The test scripts that you've written to go with the Inline::C module can be used without modifcation with your XS distro, if you decide to make the switch.)

All XS modules that I have written start off as Inline::C code (mainly because I need to "test it as-I-go"), and then the XS file gets written by InlineX::C2XS when everythng is working as it should.

Cheers,
Rob

Reply via email to