I've read through the "What's new in Groovy 2.0" and I'm a bit confused about when to use @CompileStatic. The article mentions that the @CompileStatic
annotation was added for developers who weren't able to take advantage of the invoke dynamic part of Java7.
So developers looking for performance improvements would not see much changes in Groovy 2.0, if they aren’t able to run on JDK 7. Luckily, the Groovy development team thought those developers could get interesting performance boost, among other advantages, by allowing type checked code to be compiled statically.
My question is, if I'm using JDK 7 and I follow the instructions to add the --indy
flag, do I need to add @CompileStatic
to see some performance increases? This blog suggests I would, but I'm not sure he compiled correctly given that he did it within Eclipse.
Update: Here are the stats when running different permutations of the Fibonacci code.
> groovy --indy FibBoth.groovy
..........Fib (non-static indy): 1994.465
..........Fib (static indy): 529.197
> groovy FibBoth.groovy
..........Fib (non-static): 1212.788
..........Fib (static): 525.671
Note: this question seems a little confusing now that I understand that the features are independent. Since the basis of the question is around the confusion from the notes that made me think the two features were related I think it makes sense not to change the question wording and allow the accepted answer that explain the differences.