Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Perl language aim at producing fast programs at runtime?

I recently had a friend tell me

"see perl was never designed to be fast"

  • Is that true?

The relevant piece of information I can find is this from Wikipedia:

The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).

But it doesn't directly talk about speed. I think that with all the text processing that it needs to do, speed of execution really matters for a language like Perl. And with all the weird syntax, elegance was never an objective, I agree.

  • Was high speed of execution one of the design objectives of Perl?
like image 914
Lazer Avatar asked Aug 31 '10 05:08

Lazer


3 Answers

There is one important aspect to be considered : algorithms. Perl secret weapons are the algorithms backing certain language features and the CPAN library.

Good algorithms trump raw execution speed for non trivial problems. It typically takes more effort to select and implement algorithms in C-like languages than in Perl. This means that for half a day coding some little tool the perl version often outperforms a C version because it was easier to make good datastructures with hashes and by using the features provided in the language and libraries.

like image 77
Peter Tillemans Avatar answered Nov 01 '22 15:11

Peter Tillemans


Once a Perl script starts running (i.e. after loading and compiling everything), it can be very speedy. It's that yucky compile-every-time that's a bit nasty.

However, I find that people don't really have to worry about how fast Perl can be. They waste all of their time by implementing stupid designs that do a lot more work than they need to do, misunderstanding key technologies, or just being boneheaded. It's not uncommon for me to help someone make their stuff go orders of magnitude faster by just tuning in the right places. That's not particular to Perl though. People have that problem with every language.

like image 25
brian d foy Avatar answered Nov 01 '22 17:11

brian d foy


Perl has always aimed toward practicality, not anything (even close to) some sort of ivory tower purity, where a few goals are given absolute priority, and others are ignored (completely or nearly so).

As such, I think it's reasonable to say that maintaining a reasonable speed of execution has always been seen as important for Perl, but there are other factors (especially things like flexibility and ease of use) that are generally more important, so if a choice has to be made between one of them and speed of execution, the other factor will generally win unless the effect on execution speed is really serious.

like image 7
Jerry Coffin Avatar answered Nov 01 '22 17:11

Jerry Coffin