3 ms·
I am eagerly waiting for JDK 7 with invokedynamic support. I will be good to see the improvements it will bring to dynamic languages like Jython and JRuby. I w
by prog 16y ago
I am eagerly waiting for JDK 7 with invokedynamic support. I will be good to see the improvements it will bring to dynamic languages like Jython and JRuby.
I wonder if Oracle is going to be conservative or go all out and consider features like tail calls.
- strlen 16y agoI would very much like a very simple, basic, tail recursion to be available in Java. Not tail call elimination in the same way as is specified by Scheme. It doesn't even require the a JVM change, it can be done by the compiler: Scala does this. You could use an annotation (@Tailrecursive) to verify that it happens (or error out). C does this with "-O2" (factorial is a bad example, unfortunately as there are algorithms that are much more naturally defined in terms of tail recursion): long factorial_helper(int n, int acc) { if (n==1) return acc; return factorial_helper(n - 1, n * acc); } becomes: factorial_helper: .LFB16: jmp .L8 .p2align 4,,7 .L6: imull %edi, %esi subl $1, %edi .L8: cmpl $1, %edi jne .L6 movslq %esi,%rax ret Looks very similar to what my own assembly would look like. Now with -O4 the assembly becomes completely unrecognizable (which is why higher level languages may be faster than lower level ones). Continuations would be another improvement possible at language rather than VM level, with same effect (allowing efficient and elegant implementation of some algorithms).