This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||
|
Groovy Paradigms
editShould "functional" be added to the list of Groovy Paradigms? It certainly seems to fit, given Groovy's extensive list of functional constructs. —Preceding unsigned comment added by 129.82.29.25 (talk) 14:30, 1 August 2008 (UTC)
Explanation of the Name "Groovy"
edit- In slang and informal language, "groovy" is an adjective describing an unspecified fashionable or desirable quality. It can also be used as a generally positive exclamation. It originated in Britain, and largely remains a British word. "Groovy" has slightly outdated connotations in recent times, although it can still be used in everyday speech.
I removed this from the article because wikipedia is not a dictionary and the definition has no relation with the programming language discussed in the article. -- Taku 02:47, Apr 25, 2005 (UTC)
I agree, and I removed the following which is even less desirable -- MarkBrooks 03:12, 13 October 2005 (UTC)
- Groovy is an adjective to describe the state of being 'cool', 'hip', or generally 'awesome'
- The lack of a sense of irony or tongue-in-cheek fun is a sad thing. The "definition" reflects the spirit of the originators of the language, and plays a valuable part in the encyclopedia entry. It's there not because Wikipedia is a dictionary but because we learn more about James Strachan and friends by seeing what the name means. We don't need the definition removed; we need it enhanced by an explanation of why they picked it. Webmink 05:18, 13 October 2005 (UTC)
- You want grins and giggles, go read the Encyclopaedia Britannica. Seriously though, I came to this article as a user seeking information, and I felt that the lead-in as written didn't add anything to my knowledge, detracted from the article's tone, and was simply an unnecessary distraction. Maybe somebody who didn't know what the word "groovy" meant would feel differently. BTW, back when this word was in common usage, I don't think "awesome" would have been used in quite the same way. Maybe you could quote the developer's reasons for choosing that name, to put the definition in context? -- MarkBrooks 09:22, 16 October 2005 (UTC)
- Attempts by several people to indicate the colloquial meaning of the term have now been discarded, not because they were bad or excessive like the original attempt (which I agreed was wrong) but simply because "wikipedia is not a dictionary". . Clearly there's demand for at least a nod towards the colloquialism. Are there any other editors of this page who wish to express an opinion? Webmink 03:43, 31 October 2005 (UTC)
- Personally, I think the original definition (the one at the top of this section) was superior to subsequent attempts and wouldn't object to its inclusion, particularly if a connection could be made with the choice of name for the programming language. Otherwise maybe a disambiguation page would be a better idea? -- MarkBrooks | Talk 01:36, 1 November 2005 (UTC)
- Since I know it would be hard to write a full article about the adjective groovy, I added the wiktionary link to satisfy those who just want a definition. Bkkbrad 12:15, 2 November 2005 (UTC)
- Cool, thanks. -- MarkBrooks | Talk 17:29, 3 November 2005 (UTC)
Features of Groovy compared to those of Java
editI believe Java does have native syntax for arrays. BDKosher 21:05, 12 February 2006 (UTC)
yes, it has --217.86.138.17 12:55, 31 October 2006 (UTC)
String[] list = { "Rod", "Carlos", "Chris" }; List<String> shorts = new ArrayList(); for (String item : list) { if (item.length() <= 4) { shorts.add(item); System.out.println(item); } }
and the syntax comparison is neither side-by-side nor representative.
To be fair, the Groovy code is using a List and not an Array (which Groovy supports, as well). However, also to be fair, the Groovy code doesn't create a second List of the short Strings and then print them. It just prints them as it finds them. The above example gets rid of the iteration through the second List, but still instantiates it and adds Strings to it.
I propose that the Java code be changed to the following:
class Filter { public static void main(String[] args) { List<String> list = Arrays.asList("Rod", "Carlos", "Chris"); for (String item : list) { if (item.length() <= 4) { System.out.println(item); } } } }
History of Groovy
editGroovy was originally conceived in 2003(?) as a more Ruby-like language for the Java Virtual Machine. Groovy Beta 1.0 announcement on James Strachan's blog —The preceding unsigned comment was added by 66.138.72.243 (talk) 03:51, 3 January 2007 (UTC).
Redirect
editIs there any particular reason why this article is at "Groovy (programming language)" rather than just at "Groovy", since the latter is just a redirect here? -- timc talk 18:36, 21 March 2007 (UTC)
- I don't see the point as well. Will create a disambig page.--sin-man 04:23, 3 April 2007 (UTC)
Markup Language support--don't see how this makes Groovy special.
editHow is markup language support any more special in Groovy than any other language? The example provided can be accomplished in a whole array of other languages using their standard libraries. This seems a pretty weak example to demonstrate a differentiating feature. Can something more robust be demonstrated that truly differentiates Groovy markup support from other languages?
Ehogberg (talk) 19:45, 29 January 2008 (UTC)
- The language that Groovy intends to be a complement for/alternative to is Java. As a matter of fact, Groovy was designed to be easy to learn for Java programmers, while offering the more powerful features found at the time in other scripting/dynamic languages such as Python and Ruby. In this context, maybe the markup example should also be provided in Java? Ogourment (talk) 16:42, 11 February 2008 (UTC)
- I added a Java example (using the XML DOM libraries provided with the Sun JDK); if I'm understanding correctly what's supposed to be special about markup languages in Groovy, it's that there's an inline syntax for building documents that A) doesn't care what format the document will ultimately be in, as long as it can be expressed as a DOM tree, and B) doesn't require explicit method calls for setting up each element and attribute. evildeathmath 16:50, 16 July 2008 (UTC)
Upon further reflection, I am tempted to add this version to the article as well:
System.out.println("<workbook>");
System.out.println(" <worksheet caption=\"Employees\">");
System.out.println(" <row fname=\"John\" lname=\"McDoe\"/>");
System.out.println(" <row fname=\"Nancy\" lname=\"Davolio\"/>");
System.out.println(" </worksheet>");
System.out.println(" <worksheet caption=\"Products\">");
System.out.println(" <row id=\"sku34510\" name=\"Veeblefeetzer\"/>");
System.out.println(" <row id=\"sku3a550\" name=\"Prune Unit Zappa\"/>");
System.out.println(" </worksheet>");
System.out.println("</workbook>");
On the one hand, it's pedantic, silly, and poor programming practice; on the other hand, it's likely what 9 out of 10 programmers would do if all they needed was a short XML snippet. evildeathmath 16:58, 16 July 2008 (UTC)
DOM Compliance
editThe article refers to an inline DOM syntax linked to DOM which is the w3c standard DOM. What i'm getting at is that DOM is an API standard whereas Groovy appears to implement it's own API, or rather allow xml construction using language features. Dylan.star (talk) 14:45, 3 September 2008 (UTC)
Groovy's syntax can be made far more compact than Java
editAre you serious? The shown examples just saves 6 or 8 characters. This is a bit more compact but not far more compact. --87.78.132.86 (talk) 09:36, 2 February 2009 (UTC)
Currently it is a better example but I find my naïve intuition doubting the validity of the groovy code:
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}
"it" is spontaneously defined? No note is made to suggest whether the use of the key-word declares it or not (ie, it is pretty obvious that both instances of "it" are separate variables, but does Groovy reserve "it" as a local variable name? or could the variable name have been chosen differently in each loop?) Either way "it" is a neat effect, just not as clear as I would hope an encylopedia example to be. --— robbiemuffin page talk 12:16, 15 April 2011 (UTC)
'it' is a defaulting name for a single argument closure (when none is provided). The following code is equivalent:
["Rod", "Carlos", "Chris"].findAll{it -> it.size() <= 4}.each{it -> println it}
Or:
["Rod", "Carlos", "Chris"].findAll{x -> x.size() <= 4}.each{x -> println x}
86.184.48.155 (talk) 15:00, 18 November 2013 (UTC)
The Java's stream API and lambdas make Java quite similar:
Stream.of("Rod","Carlos","Chris").filter(x -> x.length() <= 4).forEach(System.out::println)
Superset?
editI find the article's claim that "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)." fairly dubious. Looking at http://groovy.codehaus.org/Differences+from+Java, it seems that there are several major changes that will break existing Java code:
- Array literals
- == operator
- For loops with multiple indexes (i.e. for(int i = 0; j = 0; etc.)
- Changing the default accessibility from package-private to public (is there even a way to use package-private in Groovy)
- No inner classes (except their new closures)
Given all these, I would be surprised if any non-trivial Java project could be compiled as Groovy. Superm401 - Talk 05:32, 9 April 2009 (UTC)
- Also, of course Java allows you to use something like:
{
int a = 3;
System.out.println(a);
}
- when you just want to create a new scope for whatever reason. This is considered ambiguous by Groovy's compiler. Superm401 - Talk 05:48, 9 April 2009 (UTC)
Yep. Claims with vague terms like "largely" and "usually". The Wordpress.com blog referenced later in the section seems to be the source. It says "Much of the time you can simply rename a .java file with the .groovy extension - the Java syntax is mostly a subset of the Groovy syntax". I don't think it can be considered a reliable source, falling foul of limitations outlined at Wikipedia:RS#Self-published_sources. FWIW, it's not my experience (calling your Java classes from Groovy is the way to go), so my personal scepticism of this self-published source is confirmed. William Avery (talk) 08:47, 9 April 2009 (UTC)
AFAIK, any Java code will be parsed correctly as Groovy code apart from anonymous inner classes (mainly due to the braces {} inside a method, that Groovy will consider a closure. AxiomShell (talk) 22:40, 28 June 2009 (UTC)
Groovy as a "standard"
editI've marked this claim in the first paragraph as "dubious." The cited source makes the claim:
"Since the passage of JSR-241, Groovy is the second standard language for the Java platform (the first being the Java language)."
but if you visit the page for JSR-241, it is clearly marked as "inactive," which means it was never made "final." It seems to me that the only sense of the word "standard" that is accurate for the JCP is a JSR in "final" status. —Preceding unsigned comment added by 132.174.23.57 (talk) 19:52, 12 February 2010 (UTC)
Wrong link
editThe link to Curly_bracket_programming_language redirects to a page that doesn't include any list of "curly bracket programming languages". 87.63.228.190 (talk) 09:51, 11 February 2011 (UTC)
Developer
editIt doesn't seem appropriate to show Guillaume as the "developer" since his involvement is primarily as project manager. Either the project should be listed (for example Python lists the Python Software Foundation) or if individuals are going to be shown then the determination should be a few (as in no more than three I think) of the developers who have done the most work (such as Jochen and ???). — Preceding unsigned comment added by JamesPaulWhite (talk • contribs) 23:29, 12 October 2012 (UTC)
You're right, but the list of despots at http://xircles.codehaus.org/projects/groovy/members didn't seem to reflect the actual developers involved until a few months ago. By excluding Codehaus administrator Ben Walding, and adding Jochen's title "Tech Lead" in his Groovy mailing list signature, we should add "Jochen Theodorou (Tech Lead), Paul King, Cedric Champeau". — Preceding unsigned comment added by Aptasii (talk • contribs) 13:55, 23 November 2013 (UTC)
Performance
edita) the two links provided were just userspace blogs, being primary sources and directly failing WP:NOTA, b) none of the links provided have shown G2 with static compilation being faster than Java in any significant way above the confirmation threshold: blog 1 [1] was obviously synthetic and got 0's in two test cases, and +/-3% for Java, Scala and G2 with CS (which constitute "almost as fast as" or "as fast as", but not "faster than"), blog 2 [2] is much better in it's benchmark quality, yet resulting in 911ms vs 917ms, giving less than 1% of difference (again, not statistically relevant, taking into account the trial was below 1s and it was only a single benchmark algorithm, not a suite).
As such, until somebody can provide verifiable, credible and/or secondary source clearly showing G2/CS being either *significally* or *organically* (repetitively and consequently) faster, I've to remove the statement "or even faster than".
For reference, some example of proper benchmark pages (providing wide benchmarking suites on variety of hardware - thus being credible enough to use despite being primary source by itself): http://benchmarksgame.alioth.debian.org/ http://www.bioinformatics.org/benchmark/ http://www.techempower.com/benchmarks/ Poponuro (talk) 21:27, 13 September 2014 (UTC)
Groovy and Java Features
editJust to be annoying, with the new Java 8 I created a one line method like the Groovy method:
Stream.of("Rod", "Carlos", "Chris").reduce((a, b) -> {if (((String) a).length() <= 4) System.out.println(a); return b;}); ====
That means that Groovy syntax is not far more compact than java (only slightly :)
Please fix the reference. רן כהן (talk) 14:51, 2 August 2015 (UTC)
- Unfortunately, the code above is not really a one line code (the 'if' and the 'return' should be on different lines). So this is a real one line Java 8 code:
- רן כהן (talk) 08:29, 1 December 2016 (UTC)
System.out.println(Stream.of("Rod", "Carlos", "Chris").filter(a -> a.length() <= 4).collect(Collectors.toList()));
Metaprogramming
editThe examples given are clearly not meta-programming but reflection/prototype extensions mechanisms. Based on the examples, it doesn't appear that Groovy supports meta-programming at all, but instead has moderate (albeit verbose) ability to extend pre-defined definitions. If it does have true meta-programming abilities like C++, D, etc, then better examples should be given. If not, the section should be rewritten or simply removed. I don't know groovy and I'm not the one to make this change. 2601:204:C002:7081:BE5F:F4FF:FE35:1B41 (talk) 08:52, 10 February 2016 (UTC)
- Since no one chimed in, I simply changed to to state prototyping (which it clearly is) and referenced the appropriate wikipedia article rather than the one that had literally nothing to do with Groovy's capabilities. The citations are still suspect though. 2601:204:C002:7081:BE5F:F4FF:FE35:1B41 (talk) 06:25, 28 February 2016 (UTC)
External links modified
editHello fellow Wikipedians,
I have just modified 2 external links on Groovy (programming language). Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
- Added archive https://web.archive.org/web/20090317025737/http://groovy.codehaus.org/Differences+from+Java to http://groovy.codehaus.org/Differences+from+Java
- Added archive https://web.archive.org/web/20120522213410/http://groovy.codehaus.org/Closures to http://groovy.codehaus.org/Closures
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}}
(last update: 5 June 2024).
- If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
- If you found an error with any archives or the URLs themselves, you can fix them with this tool.
Cheers.—InternetArchiveBot (Report bug) 11:20, 24 October 2017 (UTC)
Criticism
editI'm rather experienced with programming languages and paradigms, having experience with dozens of languages such as Scala and Haskell. A went through all the Groovy documentation on their website today. It was sad to see there's very little criticism about the language in the article here. Here's a list of thoughts I came up with:
- I'd say most of the language features are tiny additions to the syntactic layer with both positive and negative effects.
- For example, adding more implicit class imports might reduce the need for typing explicit imports, but compiling with those classes might affect the compile/runtime performance (e.g. loading).
- Many of the operators and other minor features take a everything but the kitchen sink (featuritis) approach - instead of calling contains you can call in, instead of compareTo you have a spaceship. Saving 4 to 6 keypresses doesn't seem like a valid reason to add features.
- Both the documentation and the article seem to compare Groovy with a dated version of Java. Now that Java has streams, basic local type inference, lambdas, static/private/default in interfaces etc., it's fair to say it has caught up Groovy quite well.
I'm pretty sure there are articles and references related to each of these points. Gotta see if I have time to consider this more. 82.128.254.60 (talk) 02:06, 20 October 2018 (UTC)