| [reply] |
Can you explain why Perl is sometimes slower than Raku then?
$ time perl -e 'for (1..1_000_000_000) {}'
real 0m30.291s
user 0m30.256s
sys 0m0.020s
$ time raku -e 'for (1..1_000_000_000) {}'
real 0m12.407s
user 0m12.436s
sys 0m0.040s
| [reply] [d/l] |
Because Raku has a better internal representation for integers than Perl's SvIV and can manage ranges lazily without reifying a large data structure. (I can't remember right now if Perl optimizes this in recent releases.)
I don't know what doing nothing a billion times in 12 or seconds has to do with my point that the semantic mismatch between a language and a target platform is difficult to manage, however.
You can port Raku to LLVM or Node or Inferno or whatever platform you want, but unless that platform can optimize grammars that require dynamic dispatch for every individual lexeme, you're going to end up with a slow Raku.
| [reply] [d/l] |