4 ms·
Raku is a significantly higher level language than most languages. Which tends to lead to slowness. Really it's faster in many places than it has any right to.
by b2gills 6y ago
Raku is a significantly higher level language than most languages. Which tends to lead to slowness.
Really it's faster in many places than it has any right to.
@a[1];
Is just shorthand for a subroutine call.
postcircumfix:< [ ] >( @a, 1 );
Which ends up calling a method.
@a.AT-POS( 1 );
Actually that is also a simplification as AT-POS is probably a multi method. Not to mention inheritance.
There is even a level under that, NQP. (simplified example below)
my $reified := nqp::getattr(@a, List, '$!reified');
my $result := nqp::atpos($reified, $pos);
All of those levels of indirection have a cost associated with them.
---
It just Rakudo on MoarVM has a bunch of optimizations to remove the needed complexity at some point. Either during compilation, or after it's been running for a while.
So with those optimizations it can sometimes beat other higher level languages.
(For some specific uses it may even sometimes meet or exceed the speed of low level languages like C/C++. Mainly for algorithmic reasons.)
More optimizations would always be nice though.
- vram22 6y agoInteresting. Thanks for the reply. Just saw it now. I get it.