Hacker News new | past | comments | ask | show | jobs | submit login

No, that is annotations that assists the compiler. In Groovy 1.X I could still write public List<MyObject> mylist = new ArrayList<MyObject>() and it would behave exactly as you would expect.



By static typing, I meant compile-time type checking, and statically-typed compilation. You describe run-time type checking in dynamically-typed compiled code which was in Groovy (without generics) from the beginning but makes the code run even slower than the already slow dynamically-typed compiled code without such run-time type checking. Run-time type checking with generics was added to Groovy from version 1.5.

Perhaps I should've used the expressions "compile-time ..." and "run-time ..." to be more accurate, but virtually everyone uses "statically-typed" and "dynamically-typed" in their place.


Correct.

Actually the Groovy developers call it optional typing, not static typing. And it has always been confusing.

Still though, if you really really need static typing at compile time, Groovy never stopped you. You have always had the possibility to call Java code from Groovy and Groovy code from Java as Groovy compiles to valid Java byte code.


The other poster is right. That is typing, that is not static type checking.

You can write code like:

List<MyObject> mylist = new HashSet<Integer>() {{ add("string"); add(1L); }}

You will get groovy.lang.GroovyRuntimeException with constructor issues.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: