currently worldwide or agile dynamic languages \u200b\u200bhave achieved great popularity in both the companies and developers (though in general in Chile and Latin America, yet enterprise-level are not highly valued.)
Groovy has attracted my attention because it is a language born with a mission to get along with Java, the virtual machine live in and support the standard data types and dynamic but adding syntactic features present in languages \u200b\u200blike Python , Smalltalk or Ruby .
Groovy source code compiles to Java bytecodes like (generating. Class files that can run directly from the virtual machine), allowing instantiate Java objects and vice versa from Groovy.
Groovy's syntax is quite similar to Java, so the learning curve is very high for developers who are familiar with it.
Most things we do with Java can be done in Groovy, eg
- Definition Definition
- packages of classes (but not internal) and methods
- control structures, except the loop for (;;)
- Control Exception
- Operators, expressions and assignments
- Literals with some variations
- Instantiation, reference and de-reference of objects, method calls
- In all is an object
- Ease in handling objects, through new expressions
- and syntax for declaring literal Various forms
- advanced flow control through new structures
- New data types and operations specific expressions
- Brevity, Groovy code is much shorter than that of Java
Y as usual and to finish this entry, see how the code would be the typical "Hello World" Groovy:
/ / Hello World in Groovy
def world = "World"
println "Hello $ world!"
/ / End
At first glance we see that:
- script can be written where there are no classes (in fact there but we need not declare it)
- No ',' at the end of each line. In Groovy is optional
- The keyword def to declare variables of type dynamic. You can also create static type variables (eg Integer)
- The comments are as in Java (/ / or /**/)
- print and println are equivalent to System.out.print and System . out.println
- parameter function println not enclosed in parentheses is optional
0 comments:
Post a Comment