News for hackers. Stuff that matters.
Re:Not Your Grandfather’s Perl by avyjit on Thursday September 08, 2022 @12:56PM (#32768298)
When you refer to modern hardware with vectorization, are you saying perl beats software that makes use of vector instructions? If so wow! Afaik perl is a plain old interpreted language with no JIT, what makes it so fast? I had an idea of perl as in the same performance category as Python, Ruby and friends.
Re:Not Your Grandfather’s Perl by cogman10 on Thursday September 08, 2022 @01:37PM (#32768900)
My assumption (and I could be wrong) is that whenever you do something that's ultimately CPU intense, perl dives into C code. The sort of stuff you do with perl tends to be a lot of string manipulation and it turns out perl is pretty hyper optimized for that sort of workload.

Other languages could do the same, but often they have a few more layers before they start running that C code.

I'd be curious to know if the perl grammar also somehow lends itself to being fairly optimizable for it's interpreter.

Re:Not Your Grandfather’s Perl by jandrese on Thursday September 08, 2022 @09:28PM (#32774233)
Perl does a kind of half JIT when you start a script. It doesn't compile fully down to native machine code, but it does parse and lex the script to build an internal representation. The code is then interpreted, but since it doesn't have to parse each line again it runs very fast and also you can interpret code on the fly in a variable so you get the best of both worlds.
Re:Not Your Grandfather’s Perl by int_19h on Thursday September 08, 2022 @10:35PM (#32774645)
This has been the usual way to implement interpreted languages for decades; Perl isn't special in that regard. JIT generally refers to generation and execution of native code specifically.
Re:Not Your Grandfather’s Perl by jandrese on Friday September 09, 2022 @12:57AM (#32775471)
I'm pretty sure bash still interprets line by line because you can mess up a script by editing it while it is executing.
Re:Not Your Grandfather’s Perl by int_19h on Saturday September 10, 2022 @02:18AM (#32788313)
bash (and other shells) are special in that regard, because they use textual substitution so heavily - to pass arguments etc.

But Python, Ruby etc all compile to bytecode, and have always done so as far as I can remember.

Re:Not Your Grandfather’s Perl by csdvrx on Thursday September 08, 2022 @01:10PM (#32768470)
> Afaik perl is a plain old interpreted language with no JIT, what makes it so fast?

IDK. I didn't waste time checking why.

My guess is that due to the much smaller code size, it reaches a sweetpoint where it fits nicely in the L1 or L2 cache.

But it's just a hunch, I couldn't prove it.

Re:Not Your Grandfather’s Perl by kstrauser on Thursday September 08, 2022 @01:29PM (#32768764)
Perl likely spends a lot more time in C than a lot of other bytecode-compiled languages like Python.

  while(<STDIN>) {
   print $_;
  }
isn't doing much of its work at the top level.