Infinite Recursion
paulbarry.com
paulbarry.com
"The same mistake is done on the Computer Language Benchmark Game. There's an Array sorting benchmark where Haskell just blows away even hand-optimized C. The secret is that the benchmark never prints out the contents of the sorted array. The C compiler isn't smart enough to recognize that the array is never actually used anywhere, but Haskell is, and so the entire benchmark basically compiles down to the equivalent of "int main() { return 0; }"."
If the recursion is indirect, for example, Scala cannot optimize tail calls, because of the limited JVM instruction set.
Why is that?
http://java.sun.com/docs/books/jvms/second_edition/html/Inst...
There's also the JMP instruction, which is similar and allows the current method's arguments to be passed to another function, discarding the current stack frame and returning to the current method's caller.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeed...
Apparently there are some performance issues with the TAIL IL instruction, though I wonder if it's really as slow as pushing a new frame on the call stack.