Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

XS or SWIG

by Sihal (Pilgrim)
on Feb 03, 2003 at 16:24 UTC ( #232284=perlquestion: print w/ replies, xml ) Need Help??
Sihal has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,
I've just read the introduction to XS and SWIG in both the camel and the Advanced Perl, and I was wondering what is the difference between them, in terms of what things are easier to do with each one, and so on.
I have a whole C++ API that I need to make available through a perl module. What would be the best choice between XS and SWIG ? (on perl 5.6.1 BTW)
My main concerns are ease of use and speed to implement (just have a few days to do the stuff, sadly).

Comment on XS or SWIG
Re: XS or SWIG
by Fletch (Chancellor) on Feb 03, 2003 at 16:31 UTC

    I've never personally used SWIG, but from what I hear it's a bit easier to pick up. The down side is that since it's targeted towards working with multiple languages you might not be able to do things in the most perly way. You also want to look at Inline and friends (specifically Inline::CPP).

Re: XS or SWIG
by MZSanford (Curate) on Feb 03, 2003 at 16:35 UTC

    Personally ...

    I find that XS makes faster code, since it does not insert another layer of abstraction like SWIG. I think that XS is the best long term solution, since it is the interface provided with perl, and creates very tightly integrated code (letting you handle argument stacks and such as needed). But, i have to admit, porting large libraries can be tedious (but worth it in my opinion)

    When i have used SWIG, i have found that quite often it creates code with minor problems that have to be fixed to get it to compile. Since SWIG creates an entire abstraction layer, this C-diving is not simple. But, if the code it creates works, it is ver fast to impliment.

    For me, SWIG is quicker to create code, but XS creates better code. Your milage may vary.


    from the frivolous to the serious
Re: XS or SWIG
by broquaint (Abbot) on Feb 03, 2003 at 16:41 UTC
      Tahnks.
      Though the discussion doesn't shed some light on what I don't understand:
      Is XS able to work with C++ code?
      Is SWIG able to ( answer yes). Wich one is faster to implement?
      From what I read SWIG might be the choice for me since I need C++ and speed and not too much C programation...
      --IN doubt, reboot --
      Solonet
Re: XS or SWIG
by zentara (Archbishop) on Feb 03, 2003 at 16:41 UTC
    I thought I would just mention one thing. Swig is NOT working flawlessly on perl5.8. It won't work for me anyways. But swig is easy, I never could figure out XS. ;-( If you are going to use it on 5.6.1 it's no problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://232284]
Approved by valdez
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-08-23 19:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls