Hacker News new | ask | show | jobs
by mfrager 4148 days ago
I hope Perl 6 has better runtime speed and memory efficiency because those are the only downsides of Perl 5. However I seriously doubt that will be the case. Perl 6 will most likely be more bloated and slow, but I very much hope that I'm wrong.

Just for reference my company's software is all built with Perl 5 and runs great. Most of the execution time is within the database calls so there is no impact from using Perl over a marginally faster runtime like Python or Java.

2 comments

When did Python become faster than Perl 5?

I'm not trying to be argumentative, but the last realistic comparisons I did had Perl running quite a bit faster. For example comparing ack to grin, which are very similar projects in Perl and Python respectively...at the time, admittedly several years ago, ack was an order of magnitude faster than grin. I also wrote a few log parsers in both Perl and Python (at a time when I was working in a Python shop, so they preferred everything be done in Python). The Perl parsers were much faster than the Python variant, for exactly the same work (again, an order of magnitude difference). Perhaps this is just an example of Perl's domain of expertise...processing text is a big part of its origin story, and has always been a big part of what people use it for. Or, perhaps Python has made remarkable performance improvements in those intervening years. I haven't worked with Python in that time, so haven't followed development. Perl 5 has gotten faster in that time, too, though, so I'd be surprised if Python is dramatically faster for the same real world tasks.

Perl5 has a lot of historical baggage that makes certain things difficult to do efficiently. For example, how objects work. There is an insane amount of indirection involved for a simple method call, and this indirection can't generally be removed if we want Perl5 to stay highly backwards-compatible. Numerics aren't particularly efficient either. Perl5's opcodes are very high-level. That makes each individual opcode pretty fast, but makes it difficult to inline stuff. Variables can have “magic” attached that can change their semantics substantially. While this is very flexible and allows to do some amazing things, this also requires this magic to be checked on each access. So Perl5 has a lot of features that rank high on “clever”, but low on “can be optimized”. Perl5 never got JIT support, and only has a couple of very experimental Perl-to-C transpilers.

What is fast is string handling and log mangling. Perl was created for that; everything else is bolted on.

I understand all that (though it's useful to cover it for folks who might not know). But, is Python faster? It carries some baggage of its own. I guess PyPy may be able to make some sorts of problems faster, and it was still nascent at the tail end of when I was using Python; I think it existed, but was nothing more than a proof of concept. Even now, I think it's a pretty limited subset of Python deployments that use PyPy.

And, you speak of numerics, which is a good example of Python's wheel house. When I worked in Python it was at Enthought (the company run by the folks who created Numeric, SciPy, and who sponsors a lot of scientific computing Python projects). Perl definitely doesn't have the numbers performance of a hybrid Python+Fortran or Python+C++ system, like you can build with Python, Numeric, SciPy, etc.

So, even back then, Python was (probably) faster than Perl in that category (Perl has science and bioinformatics libraries, which may have been comparable back then, but certainly aren't now), and I guess it's unfair to compare Perl's strength to Python's weakness, and vice versa.

Nonetheless, I suspect Perl is not slower than Python in the general case. One would probably have to talk about specific tasks and implementations to figure it out.

With perl5 + Moose, perl6 beats perl5. In startup time and run time. With simple small scripts the small startup footprint of perl5 still elevates it over perl6.

perl6 has much more features than perl5, it's a completely different world. I wouldn't call that bloat.

Wonder how Moo compares?