jfroebe has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I've been wondering about this for some time.. is it worth rewriting a program to be pure perl or write a wrapper for the program?

yup, I know it depends but I'm thinking of the distribution part...

for example: there isn't a cpan module for a pure perl module for cvs.. only a series of wrappers for the command line. What does this mean? If I'm going to distribute a perl app, I'm going to have to install cvs as well.

I understand that there are many programs where a wrapper is necessary due to licensing (i.e. RAR) or because a pure perl implementation would be far too slow (i.e. GUI). However, there are many more where it would make sense for a pure perl implentation (the various rcs implementations).

Jason L. Froebe

I'm not explaining myself very well I'm afraid.

Team Sybase member

No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

  • Comment on create wrappers for existing tools or rewrite?

Replies are listed 'Best First'.
Re: create wrappers for existing tools or rewrite?
by Ovid (Cardinal) on Dec 31, 2004 at 01:54 UTC

    Well, given that you know you've asked a vague question and you're probably expecting vague answers, my response is: it depends (as you well know :)

    What will cost less money? Would rewriting the app or writing a wrapper be less expensive? Also, if you rewrite instead of wrap, what is the potential impact if your code does not work properly? I wouldn't be too happy to hear about programmers rewriting perfectly good ATM software, for example.

    Of course, if this is just for fun and you have spare time, rewrite away! Ain't nothin' wrong with havin' fun with what you do.

    Cheers,
    Ovid

    New address of my CGI Course.

Re: create wrappers for existing tools or rewrite?
by holli (Abbot) on Dec 31, 2004 at 10:06 UTC
      I'd say start off with the wrapper, once you have added an extra layer of abstraction it makes it easier to start changing things underneath. Assuming the wrapper is written well as a interface you should be able to change the implementation of it underneath without impacting any code that uses the wrapper.

      So you can mix the use of old code and new code by migrating each sub as you go. So you will end up with a pure perl implementation of your wrapper, the orginal system call implementation and probably a mixed one along the way as well.

      sometimes this is called programming by contract, your wrapper forms the contract that states what your implementation has to do.