Is there a PERL compiler?

Discussion in 'Perl Misc' started by DG, Jul 27, 2004.

  1. DG

    DG Guest

    I'm just curious. Is there a PERL compiler available?

    I've got a PERL program that, over the years, has grown fairly large. It
    does a lot and does it reliability. So I'd like to keep it. But it's
    getting kind of slow. So I was wondering if there was a compiler available
    (so I don't have to rewrite it in a compiled language).

    If a PERL compiler is not available, is there a PERL to C++ or PERL to JAVA
    translator available?

    Thanks,
    DG
    DG, Jul 27, 2004
    #1
    1. Advertising

  2. DG

    Paul Lalli Guest

    On Tue, 27 Jul 2004, DG wrote:

    > I'm just curious. Is there a PERL compiler available?
    >
    > I've got a PERL program that, over the years, has grown fairly large. It
    > does a lot and does it reliability. So I'd like to keep it. But it's
    > getting kind of slow. So I was wondering if there was a compiler available
    > (so I don't have to rewrite it in a compiled language).
    >
    > If a PERL compiler is not available, is there a PERL to C++ or PERL to JAVA
    > translator available?



    (Perl is the language, perl is the interpeter. PERL doesn't exist.
    People here are touchy about that. Read perldoc -q difference).

    Read the FAQ answer to your question:

    perldoc -q compile


    Paul Lalli
    Paul Lalli, Jul 27, 2004
    #2
    1. Advertising

  3. DG wrote:

    > I'm just curious. Is there a PERL compiler available?


    There's something that's usually referred to as a "Perl compiler"
    included with recent versions, but it doesn't do what you seem to be after.

    It's very rare that a significant part of a script's overall execution
    time is spent parsing Perl text and producing byte code from it, so the
    performance gain from using Perl's "compiler" is usually nil. It's meant
    as more of a packaging and distribution mechanism than as an optimizer.

    See 'perldoc -q compile'

    > is there a PERL to C++ or PERL to JAVA
    > translator available?


    Yes - it's called a "programmer". ;-)

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Jul 27, 2004
    #3
  4. Paul Lalli wrote:

    > PERL doesn't exist.


    Of course it does - although a lot of people confuse it with Perl. One
    of my favorite CPAN modules is Inline::pERL, which allows you to embed
    this powerful language in your Perl programs. From the Inline::pERL docs:

    "PERL is a programming language for writing CGI applications. It's main
    strength is that it doesn't have any unnecessary warnings or strictures.
    It is a direct descendent of Perl, a programming language which was used
    mainly by programmers. However, the original language required too much
    reading and thinking and so PERL was developed as a language which was
    more in tune with the requirements of the Internet age."

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Jul 27, 2004
    #4
  5. DG

    Paul Lalli Guest

    On Tue, 27 Jul 2004, Sherm Pendley wrote:

    > Paul Lalli wrote:
    >
    > > PERL doesn't exist.

    >
    > Of course it does - although a lot of people confuse it with Perl. One
    > of my favorite CPAN modules is Inline::pERL, which allows you to embed
    > this powerful language in your Perl programs. From the Inline::pERL docs:
    >
    > "PERL is a programming language for writing CGI applications. It's main
    > strength is that it doesn't have any unnecessary warnings or strictures.
    > It is a direct descendent of Perl, a programming language which was used
    > mainly by programmers. However, the original language required too much
    > reading and thinking and so PERL was developed as a language which was
    > more in tune with the requirements of the Internet age."


    I stand humbly corrected. :)

    Paul Lalli
    Paul Lalli, Jul 27, 2004
    #5
  6. DG

    peter pilsl Guest

    DG wrote:
    > I'm just curious. Is there a PERL compiler available?
    >
    > I've got a PERL program that, over the years, has grown fairly large. It
    > does a lot and does it reliability. So I'd like to keep it. But it's
    > getting kind of slow. So I was wondering if there was a compiler available
    > (so I don't have to rewrite it in a compiled language).
    >


    as the other already said everything why a Compiles is not what you are
    looking for I want to add some hints what you are actually looking for:

    * use a so called "profiler" on your programm. A profiler analyzes your
    running programm and tell you how many time it spends in certain
    codelines or subroutines. Many times very simple changes in your code
    can boost performance of the whole appliction many times.
    Profiling helps you to find the piece of code that is worth deeper
    examination and thinking. And then ... maybe then .. you can think about
    rewriting a few lines of critical code in C++ or a even faster language
    (assembler but I dont actually know if really people write assemblercode
    for timecritical routines)

    * if your program deals with lot of data, you might look on your
    data-structure and your underlying data-storage. Tuning a database,
    using different methods for plainfile-seek etc. can save lot of resources.

    * monitor and tune your system. Buy more memory if this is a bottleneck,
    buy a faster harddisk. Turn on udma if you havent already ...


    peter

    --
    http://www2.goldfisch.at/know_list
    http://leblogsportif.sportnation.at
    peter pilsl, Jul 27, 2004
    #6
  7. DG

    Eric Bohlman Guest

    "DG" <> wrote in
    news:OkxNc.38363$8_6.33942@attbi_s04:

    > I've got a PERL program that, over the years, has grown fairly large.
    > It does a lot and does it reliability. So I'd like to keep it. But
    > it's getting kind of slow. So I was wondering if there was a compiler
    > available (so I don't have to rewrite it in a compiled language).


    As others have pointed out, that's not the way to speed up your code. The
    way to speed it up is to profile it in order to find out where most of the
    time is being taken, determine how much of that time is actually
    attributable to your code as opposed to things like IO that are beyond your
    control, and then speed up those parts (first by seeing if you could use
    better algorithms or data structures; if not by rewriting them in C or the
    like and using XS or Inline::* to integrate them with the rest of your
    code).

    Note that except in cases where there's a glaringly obvious bad choice of
    algorithm or data structure (e.g. a bubble sort used inside a very tight
    loop), most programmers' intuitions as to what part of the code is taking
    the most time are usually *very* poor. This is particularly the case
    in a language like Perl, where one construct that looks "obviously" faster
    than another can actually be slower because the first one does most of its
    work in behind-the-scenes, highly-optimized code within perl itself whereas
    the second one involves a lot of interpretation overhead. Thus the need for
    profiling.
    Eric Bohlman, Jul 27, 2004
    #7
  8. DG

    Anno Siegel Guest

    Abigail <> wrote in comp.lang.perl.misc:

    > @;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
    > 0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
    > ;print@;[@;{A..Z}];


    Oh, let's see...

    my $orig = 'Just another Perl hacker,';
    my @permute;
    @permute[
    map $_->[ 1],
    sort { $a->[ 0] cmp $b->[ 0] }
    do { my $n = 0; map [ $_, $n++ ], split //, $orig}
    ] = 0 .. length( $orig) - 1;

    print +(sort split //, 'Joel, Preach sartre knuth')[ @permute], "\n";
    __END__

    Just another Perl hacker,

    Yup, everything in place.

    Anno
    Anno Siegel, Jul 27, 2004
    #8
  9. DG

    Guest

    "DG" <> wrote:
    > I'm just curious. Is there a PERL compiler available?
    >
    > I've got a PERL program that, over the years, has grown fairly large. It
    > does a lot and does it reliability. So I'd like to keep it. But it's
    > getting kind of slow.


    Programs don't just get slower all by themselves. In fact, they generally
    get faster, as they are moved to progressively less obsolete hardware. So,
    what did you do to it that made it slower? Whatever it was, that's the
    thing to look at for speeding it up.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Jul 27, 2004
    #9
  10. DG

    Uri Guttman Guest

    >>>>> "D" == DG <> writes:

    D> I've got a PERL program that, over the years, has grown fairly
    D> large. It does a lot and does it reliability. So I'd like to keep
    D> it. But it's getting kind of slow. So I was wondering if there
    D> was a compiler available (so I don't have to rewrite it in a
    D> compiled language).

    profile it and rewrite/redesign the slow stuff. i will wager if you call
    it PERL that it isn't written well and can be sped up a fair amount. but
    you would need to hire someone who knows Perl and not PERL to do so.

    <i am available for refactoring/redesign/speedups>

    :)

    uri

    --
    Uri Guttman ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Jul 28, 2004
    #10
  11. DG

    Guest Guest

    Abigail <> wrote:
    :
    : <> translator available?

    : Well, perl *IS* a compiler. Perl code gets compiled before it gets
    : executed.

    : If you program is getting too slow, you should think about redesigning
    : your code. An automatic translation from Perl to <whatever> will not
    : help you.

    Proper coding makes a huge, huge difference and outweighs ever benefit
    (doubtful, though) from any translation to other compilable languages.
    Just look at the following example:

    #!/usr/bin/perl

    # A run time test

    for ($i=0; $i<=50000; $i++) {
    # 1. Conventional way to concatenate strings
    # $string=$string."a"
    # 2. Perl idiom to do the same thing
    $string.="a"
    }

    Try the example yourself - save it, e.g. as "runtime.pl", and do
    a "$ time ./runtime.pl", once uncommenting the first concatenation
    style, then the second. The program itself doesn't produce any
    output; just look at the results of "time".

    Try again and increase the number of loop iterations. You'll be
    flabberghasted after seeing the differences.

    In many cases, testing the proper function of a program is done with
    a set of sample or test data which are structurally identical to the
    real-life problem given without matching the quantities involved.

    So, if somebody tests a program with a set of e.g. 100 lines of data
    the problem looks fine, but given 10000 lines of input, the time used
    is not 100 times, but 100 square times, -> 10000 times, which starts
    becoming noticeable.

    I've alwas told my students to use real life data, not just "white mice".

    Oliver.
    --
    Dr. Oliver Corff e-mail: -berlin.de
    Guest, Jul 29, 2004
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yan
    Replies:
    0
    Views:
    1,105
  2. Jack Wright
    Replies:
    5
    Views:
    604
    Shiv Kumar
    Jan 19, 2004
  3. Merciadri Luca
    Replies:
    5
    Views:
    1,059
    Merciadri Luca
    Oct 14, 2010
  4. ngoc
    Replies:
    7
    Views:
    160
    zentara
    Jul 14, 2005
  5. sm
    Replies:
    3
    Views:
    96
    Sisyphus
    Mar 14, 2006
Loading...

Share This Page