If I understand correctly Groovy is dynamically typed but since it's almost a superset of Java, static type information may optionally be provided. This could be useful if writing something where only a few parts are performance critical while avoiding the friction of using multiple languages. Type annotations could be provided only for the performance critical parts.
What is the performance penalty for using Groovy instead of Java in functions/classes where the Java-like subset is used and static type annotations are provided?
Declaring types in groovy doesn't magically speed things up. It's still groovy code and needs to go through the MOP in case something got dynamically changed. You don't get static linking just because you've given type information.
For performance sensitive things that the groovy code just isn't fast enough for, you'll need to write real java code.
This question is very similar to a previous one where I gave an answer digging into the generated byte code showing how typing something doesn't speed things up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With