![]() |
|
| Paradigm(s) | Object-oriented, imperative, scripting, functional |
|---|---|
| Appeared in | 2003 |
| Designed by | Java Community Process |
| Developer | Guillaume Laforge (Project Manager and JSR-241 Spec Lead) |
| Stable release | 2.0.0 (June 28, 2012) |
| Typing discipline | Dynamic, strong, duck |
| Influenced by | Java, Python, Ruby, Perl, Smalltalk, Objective-C |
| Platform | Java Virtual Machine |
| OS | Cross-platform |
| License | Apache License v2.0 |
| Website | http://groovy.codehaus.org/ |
Groovy is an object-oriented programming language for the Java platform. 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 (JVM) bytecode and interoperates with other Java code and libraries. Most Java code is also syntactically valid Groovy.
Groovy 1.0 was released on January 2, 2007.
Contents |
James Strachan first talked about the development of Groovy in his blog in August 2003[1]. 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 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 many changes that were made.
In July 2009, Strachan wrote on his blog, "I can honestly say if someone had shown me the Programming in Scala book by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I'd probably have never created Groovy."[2] Strachan left the project silently a year before the Groovy 1.0 release in 2007.[citation needed]
Many (but not all) valid Java files are also valid Groovy files. Although the two languages are similar, Groovy code can be more compact, because it does not require all the elements that Java requires.[3] This makes it possible for Java programmers to gradually learn Groovy by starting with familiar Java syntax before acquiring more Groovy idioms.[4]
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").[5]
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}
Groovy provides 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]
Unlike Java, Groovy source code file can be executed as an (uncompiled) script if it contains code outside any class definition, is a class with a main method, or is a Runnable or GroovyTestCase. A Groovy script is fully parsed, compiled, and generated before execution (similar to Perl and Ruby). (This occurs under the hood, and the compiled version is not saved as an artifact of the process.)[6]
GroovyBeans are Groovy's version of JavaBeans. Groovy implicitly generates accessor and mutator methods. In the following code, setColor(String color) and getColor() are implicitly generated; and the last two lines, which appear to access color directly, are actually calling the implicitly generated methods.[7]
class AGroovyBean { String color } def myGroovyBean = new AGroovyBean() myGroovyBean.setColor('baby blue') assert myGroovyBean.getColor() == 'baby blue' myGroovyBean.color = 'pewter' assert myGroovyBean.color == 'pewter'
Groovy offers simple, consistent syntax for handling lists and maps, reminiscent of Java's array syntax.[8]
def movieList = ['Dersu Uzala', 'Ran', 'Seven Samurai'] //looks like an array, but is a list assert movieList[2] == 'Seven Samurai' movieList[3] = 'Casablanca' //adds an element to the list assert movieList.size() == 4 def monthMap = [ 'January' : 31, 'February' : 28, 'March' : 31 ] //declares a map assert monthMap['March'] == 31 //accesses an entry monthMap['April'] = 30 //adds an entry to the map assert monthMap.size() == 4
Many integrated development environments support Groovy:
sensagent's content
Dictionary and translator for handheld
New : sensagent is now available on your handheld
Advertising ▼
Webmaster Solution
Alexandria
A windows (pop-into) of information (full-content of Sensagent) triggered by double-clicking any word on your webpage. Give contextual explanation and translation from your sites !
SensagentBox
With a SensagentBox, visitors to your site can access reliable information on over 5 million pages provided by Sensagent.com. Choose the design that fits your site.
Business solution
Improve your site content
Add new content to your site from Sensagent by XML.
Crawl products or adds
Get XML access to reach the best products.
Index images and define metadata
Get XML access to fix the meaning of your metadata.
Please, email us to describe your idea.
Lettris
Lettris is a curious tetris-clone game where all the bricks have the same square shape but different content. Each square carries a letter. To make squares disappear and save space for other squares you have to assemble English words (left, right, up, down) from the falling squares.
boggle
Boggle gives you 3 minutes to find as many words (3 letters or more) as you can in a grid of 16 letters. You can also try the grid of 16 letters. Letters must be adjacent and longer words score better. See if you can get into the grid Hall of Fame !
English dictionary
Main references
Most English definitions are provided by WordNet .
English thesaurus is mainly derived from The Integral Dictionary (TID).
English Encyclopedia is licensed by Wikipedia (GNU).
Copyrights
The wordgames anagrams, crossword, Lettris and Boggle are provided by Memodata.
The web service Alexandria is granted from Memodata for the Ebay search.
The SensagentBox are offered by sensAgent.
Translation
Change the target language to find translations.
Tips: browse the semantic fields (see From ideas to words) in two languages to learn more.
last searches on the dictionary :
computed in 0.062s