What does MoarVM do with your Perl 6 code?
perl6advent.wordpress.com
perl6advent.wordpress.com
According to http://perl6advent.wordpress.com/2014/12/01/the-state-of-per... "In 2014, MoarVM has become the de facto standard backend for the Rakudo Perl 6 compiler. Parrot and JVM are still supported as backends, but MoarVM provides much lower memory usage, faster startup time, and is significantly faster than parrot at runtime. Rakudo on MoarVM also has concurrency support, including reactive programming."
If the topic is optimization improvements, is the improvement in question one that assigns the eventual value directly to $i? :-) (Or if that's literally the whole program, optimizes it away to nothing.)
First of all, keep in mind that the loop isn't empty - it includes the iteration condition.
Then think you've got a loop of 100000000 iterations. Are you suggesting we should unroll that so that it can be constant folded using conventional techniques? That's going to be prohibitively expensive in terms of space and time.
If we can't unroll we could peel it an iteration at a time, but we'll need some kind of analysis that will detect that the body of the loop can be constant folded, while at the still time having the control flow nodes in there. That might well be possible, but I'm not personally aware of how to do it - are you?
With that said, I wrote the C equivalent of that Perl code, compiled -O0, disassemble, and it's what you'd expect.. add, mov, cmp, jg. At O3, the entire program is replaced by the no op: xor eax, eax.
I am surely comparing apples and oranges here and missing your point about the control flow nodes, but gcc is making such an optimization on a naive implementation so it seems conceptually possible in a more dynamic environment if the same limitations can be calculated to be present on such an example, maybe?
I honestly don't know how much magic you can inject into Perl6, but there have to be languages dynamic enough that allow you to override integer increments and make $i=10; ++$i return an array of oranges. Possibly even from another thread while you're iterating.
Almost all of its developers quit around the same time:
http://www.modernperlbooks.com/mt/2013/02/goodnight-parrot.h...