Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

What defines "Pure Perl"?

by dh1760 (Acolyte)
on Sep 08, 2008 at 13:45 UTC ( [id://709757]=perlquestion: print w/replies, xml ) Need Help??

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

There are often threads on PM and other perl code-related sites that make reference to "pure perl", yet I've not been able to find an actual definition of pure perl.

If I had to answer my own question, I would say that "pure perl" defines a perl script that is written using solely the base language and built-in functions. Essentially a script that does not reference add-on packages via "use" directives.

Is this reasonably on target, or have I completely misunderstood the concept of pure perl?

Thanks in advance!

-DaveH (dh1760)

Replies are listed 'Best First'.
Re: What defines "Pure Perl"?
by Corion (Patriarch) on Sep 08, 2008 at 13:48 UTC

    "Pure Perl" refers to not using the C-extensions ("XS") and thus, not requiring a working C compiler setup. This is often preferred because in many environments, you don't have the luxury of having a C compiler that works with the version of Perl supplied by your vendor. Having a pure Perl module also makes it easy to include the code in your program by copying the source code of the module into your program directly.

      An example of such a platform is Solaris, since Sun wants big bucks for the native compiler. While there are hacks for using gcc to build XS modules, they are just that: hacks. Pure perl is vastly preferred.
        gcc works well (and is even shipped) with Solaris 9 and later. Before that gcc worked well for xs, but you needed to get it from sunfreeware or some other packager. -Waswas


        -Waswas

        Actually I believe that the Sun Forté compiler is now available for free for Solaris 10, but I haven't looked closely.

        $35.00 doesn't strike me as "big bucks"

      I believe it often also includes not using any third-party software (e.g. sendmail) not explicitly part of the scope of the module.

      lodin

Re: What defines "Pure Perl"?
by betterworld (Curate) on Sep 08, 2008 at 13:52 UTC

    The point is that it's possible to write Perl modules in C, which means that you can use the module like any other Perl module via "use", but it's actually implemented in C, and most often through the interface of XS.

    The motivations for this are that you can do nasty low-level system things in C; and that some things are faster. For instance, many modules like List::Util have a Pure Perl implementation as well as an XS implementation. If the latter has been compiled, List::Util is supposed to be faster.

    The downside is that you need a working C compiler to install these modules; and that's why some modules are advertised as "Pure Perl", i.e. easy to install.

      Thanks for the quick response!

      I understand now that a Pure Perl module is one that doesn't require a C compiler resident on the system in order to be able to install it, and a Pure Perl solution is one that does not include any references to other modules that are not themselves Pure Perl.

      -DaveH (dh1760)
Re: What defines "Pure Perl"?
by Anonymous Monk on Sep 08, 2008 at 13:56 UTC
    http://search.cpan.org/dlsip
    L - Language Used
    p  -  Perl-only, no compiler needed, should be platform independent
    c  -  C and perl, a C compiler will be needed
    h  -  Hybrid, written in perl with optional C code, no compiler needed
    +  -  C++ and perl, a C++ compiler will be needed
    o  -  perl and another language other than C or C++

      DLSIP ! How terribly '90s!

      The usefulness of the DLSIP categorisation is predicated on packages appearing in The Module List. I think the current statistics are something like less than one in three distributions. The more recent the first release of the dist., the more likely the author has never even heard about it, nor knows what to do about it. META.yml is shaping up as the way to store metadata about a distribution.

      • another intruder with the mooring in the heart of the Perl

        It's not that the distributions appear in the Module List, which is unmaintained and dead, but that people have registered their namespaces in PAUSE so they can more PAUSE maintenance features and can set some meta-data in PAUSE. Most of the meta-data should probably be in the distribution itself, but most of them don't have that.

        THE DLSIP categorization is still useful though, because it doesn't matter how many other modules use it for it to matter for one distribution. The categorization itself is not useful because of its source, and the same categorization would be useful in META.yml. Now that META.yml 1.4 is the current version, maybe we could add more categorization stuff to the spec for the next version. :)

        --
        brian d foy <brian@stonehenge.com>
        Subscribe to The Perl Review
Re: What defines "Pure Perl"?
by Tanktalus (Canon) on Sep 08, 2008 at 17:48 UTC

    I've also noticed that some people consider "pure perl" to be the same as "core perl" - that is, just the modules that come with perl itself. This definition has annoyed me, but I thought it worth pointing out. This definition, which is closer to your guess, still allows for "use" directives - as long as what you're using comes with perl itself, such as File::Copy or File::Spec or even, on Windows, Win32.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://709757]
Approved by moritz
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found