Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will groovy (grails) give you compile time checking like java?

Will groovy (grails) give you compile time checking like java?

If you always specify the type, will that change things much?

like image 968
Blankman Avatar asked Jun 21 '10 19:06

Blankman


People also ask

Which is faster Java or Groovy?

"With the @CompileStatic, the performance of Groovy is about 1-2 times slower than Java, and without Groovy, it's about 3-5 times slower.

What is the difference between Groovy and Grails?

Groovy is an object-oriented programming language for the Java platform. Grails is an open-source web application framework. So, what is the link between them? It turns out that Groovy is a perfect language to use as a domain-specific programming language to build web applications using Grails.

Is Groovy interpreted or compiled?

Groovy is a compiled language, but it allows you to execute scripts. Calling groovy like you did compiles and runs the script.

What is checked during compile time?

Compile-time checking occurs during the compile time. Compile time errors are error occurred due to typing mistake, if we do not follow the proper syntax and semantics of any programming language then compile time errors are thrown by the compiler.


1 Answers

Since Groovy 2.0 it is possible to check types at compile time. Annotations can be used on class or method: @TypeChecked or @CompileStatic. The 1st one tells compiler to do type checking during compilation and the 2nd one force it to do 'static compilation' which more or less results with binary code like from native JAVA compiler. Of course, usage of the 2nd annotation involves type checking by itself.

Grails 2.2 is the first release that uses Groovy 2.0.

like image 80
topr Avatar answered Nov 15 '22 18:11

topr