Pular para o conteúdo

Conheça Walt Disney World

Groovy (programming language)

Groovy
Groovy groovy.png
Paradigm Object-oriented, scripting
Appeared in 2003
Designed by JCP
Developer Guillaume Laforge
(Project Manager and
JSR-241 Spec Lead)
Stable release 1.6.5 (2009-10-02; 18 days ago)
Preview release 1.7-beta-1 (2009-07-31; 2 months ago)
Typing discipline Dynamic, strong, duck
Influenced by Java, Python, Ruby, Perl, Smalltalk
OS Cross platform (JVM)
License Apache License v2.0
Website http://groovy.codehaus.org

Groovy is an object-oriented programming language for the Java platform as an alternative to the Java programming language. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform.

Groovy uses a Java-like bracket syntax. It is dynamically compiled to Java Virtual Machine bytecode and works seamlessly with other Java code and libraries. Most Java code is also syntactically valid Groovy.

Groovy 1.0 was released on January 2, 2007.

Contents

Features

The Groovy language is largely a superset of the Java language. One can usually rename a .java file to a .groovy one and it will work (though there are a few incompatibilities). Groovy has a number of features not found in standard Java. This makes the learning curve for Java developers gradual, since they can start with Java syntax and gradually learn to add Groovy features.[1]

Groovy features not available in Java include both static and dynamic typing (with the def keyword), closures, operator overloading, native syntax for lists and associative arrays (maps), native support for regular expressions, polymorphic iteration, expressions embedded inside strings, additional helper methods, and the safe navigation operator "?." to automatically check for nulls (for example, "variable?.method()", or "variable?.field").[2]

Groovy's syntax can be made far more compact than Java. For example, a declaration in Standard Java 5+ such as:

 for (String it : new String[] {"Rod", "Carlos", "Chris"})
     if (it.length() <= 4)
         System.out.println(it);

can be expressed in Groovy as:

 ["Rod", "Carlos", "Chris"].findAll{it.size() <= 4}.each{println it}

One noteworthy feature of Groovy is its native support for various markup languages such as XML and HTML, accomplished via an inline DOM syntax. This feature enables the definition and manipulation of many types of heterogeneous data assets with a uniform and concise syntax and programming methodology.[citation needed]

History

James Strachan first talked about the development of Groovy in his blog in August 2003. Several versions were released between 2004 and 2006. After the JCP standardization process began, the version numbering was changed and a version called "1.0" was released on Tuesday, January 2, 2007. After various betas and release candidates numbered 1.1, on December 7, 2007, Groovy 1.1 Final was released and immediately rebranded as Groovy 1.5 as a reflection of the great improvement made.

IDE support

Many integrated development environments support Groovy:

See also

Notes

References

External links