Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Extending perl with C dynamic library.

by Martin90 (Sexton)
on Aug 17, 2013 at 12:26 UTC ( #1049833=note: print w/replies, xml ) Need Help??


in reply to Re: Extending perl with C dynamic library.
in thread Extending perl with C dynamic library.

BrowserUk , huge thanks for this !

I've tested Inline:C version and it works almost the same way as XS. For me big adventage of Inline:C is the fact that code is more visable and well separated.

But I didn't mentioned why I am looking for another way of produce dynamic libraries (.so) if I already have XS solution.

The answer is .so file size. With XS and Inline::C I get .so file size aprox. 50 kb (suprisingly big for just one C function !) I have seen other people .so with much more complex code involved several function with just 10-20 Kb size.

Well, why even simple .so weight so much ? How to slim it down ? ;)

Thanks.
  • Comment on Re^2: Extending perl with C dynamic library.

Replies are listed 'Best First'.
Re^3: Extending perl with C dynamic library.
by syphilis (Chancellor) on Aug 17, 2013 at 13:02 UTC
    How to slim it down ?

    Try stripping the symbols from it:
    strip -s your.so
    Often, but not always, perl is built with a cflags setting that ensures that the shared object is automatically stripped.

    Cheers,
    Rob
Re^3: Extending perl with C dynamic library.
by BrowserUk (Pope) on Aug 17, 2013 at 16:24 UTC
    Well, why even simple .so weight so much ? How to slim it down ? ;)

    Quite frankly, I wouldn't bother.

    If you achieved a full 40k saving it only represents 0.001% of the most modestly configured workstation or server memory.

    And that's if the whole of the on-disk representation actually gets loaded into memory, which it probably doesn't.

    And if your thought is smaller file will take less time to load. The time spent finding the directory entry and seeking to the file will completely swamp any difference in loading 10k instead of 50k. It is doubtful if you could ever actually measure any difference it might make.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Extending perl with C dynamic library.
by Monk::Thomas (Friar) on Aug 19, 2013 at 10:16 UTC
    Counter-Question: WHY do you want to use C?

    Or put differently: What is your real goal?

    Do you just want to see it work? Do you want to make something more performant? Is there something that's not implementable in perl?

    I'm asking this because shortly after trying to implement inline C you're worried about size of the resulting library. To me the first priority would be: Is it worth it? And that means some kind of performance/functionality test. Stripping down the C-beast afterwards is only necessary if there is an actual gain - otherwise stay with pure perl for easier portability, maintainability, conciseness...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049833]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-12-11 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (288 votes). Check out past polls.

    Notices?