Is there a PERL compiler?

D

DG

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
 
P

Paul Lalli

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
 
S

Sherm Pendley

DG said:
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--
 
S

Sherm Pendley

Paul said:
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--
 
P

Paul Lalli

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
 
P

peter pilsl

DG said:
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
 
E

Eric Bohlman

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.
 
A

Anno Siegel

Abigail said:
@;=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
 
C

ctcgag

DG said:
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
 
U

Uri Guttman

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
 
G

Guest

:
: <> 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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top