开发者

Does Perl language aim at producing fast programs at runtime?

开发者 https://www.devze.com 2023-01-14 00:11 出处:网络
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:

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 Per开发者_如何学Gol. 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?


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.


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.


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.


I would have said that a language that designed for optimal run time performance would not have constructs that allow compiling while running. So no, perhaps.


It became a design objective as of Perl 5.0. But keep in mind it is still interpreted, so it is fast for an interpreted language.

0

精彩评论

暂无评论...
验证码 换一张
取 消