• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Groovy newbie questions

 
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi good day to all,

1. is there any sample show how groovy used on top of java ?

2. groovy mainly use for web application ? is groovy something like jsp ?

3. how stable of groovy ?

4. is there any good reference site for groovy ?

5. is groovy tend to improve java application performance?

thank you very much for guidance
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

1. is there any sample show how groovy used on top of java ?

2. groovy mainly use for web application ? is groovy something like jsp ?

3. how stable of groovy ?

4. is there any good reference site for groovy ?

5. is groovy tend to improve java application performance?



1. Groovy pretty much "is" Java with an augmented and relaxed syntax and a different compiler. So you don't have to run "on top of" anything. Most anything you can code in Java you can code in Groovy. You would need to groovyc instead of javac when you want to compile. (Noting that compilation is optional.) Here's an example Groovy script:

You can run in interpreted mode and use the BeanScriptingFramework approach towards embedding. That would give you Groovy "on top of" Java.
2. Groovy is a general purpose programming language. As such it can be used for templating (which it has lots of wild support for), web apps (see GSP or Grails), desktop GUIs (using something like SwingBuilder), or anything you need.
3. Groovy just released it's 1st released candidate about a week ago. Prior versions to that have showed problems mostly with special use cases. I'd say it's pretty stable but that's entirely subjective.
4. See the docs on its home page: http://groovy.codehaus.org/Documentation
5. Groovy is inteded to improve Java's usability. In other words it's more programmer friendly making programs easier to write and easier to maintain. Goals like this are always in opposition to performance. Consider your task. If you need nose-bleed critically high performance (which many modern apps really do not need) then you would use a lower level programming language like C. That said Groovy's performance, as far as I can tell, has been acceptable. I would say in most typical uses performance of the language would not be a concern.
 
author
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

1) e.g.
println 'hi'
is equivalent to
System.out.println("Hi");
The groovy code is not only a shortcut for the Java version. It works with the same Java classes and objects. In this case the java.lang.System class, the standard OutputStream, its println method and the java.lang.String argument.

2) Groovy is an all-purpose language.
3) Fortune-500 companies use it in production for mission-critical apps.
4) http://groovy.codehaus.org
5) No. In fact, Groovy will always be slower than Java.
The purpose of Groovy is to make development simpler and faster.

regards
Dierk
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. In fact, Groovy will always be slower than Java.

Is this statement assuming running in interpreted mode? Where as if you were to groovyc all your groovy code and run it, it should be identical to have written all the code in Java (syntax, vs groovy syntax, I know it's all java), right?
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no "interpreted mode". Groovy is always compiled to bytecode and the bytecode is executed.

The reason why Groovy is always going to be slower than Javav (unless Sun makes some really amazing extensiond to the JVM) is that Geoovy is dynamic. So things like method call and proerty acess are not comiled as direct operations on the object - they are performaed by calls to the object's metaclass. This indirection gives flexibility but at a cost
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tug Wilson:
There is no "interpreted mode". Groovy is always compiled to bytecode and the bytecode is executed.

The reason why Groovy is always going to be slower than Javav (unless Sun makes some really amazing extensiond to the JVM) is that Geoovy is dynamic. So things like method call and proerty acess are not comiled as direct operations on the object - they are performaed by calls to the object's metaclass. This indirection gives flexibility but at a cost



Ahh, ok. I understand now. I'm coming around. Is Groovy as slow as Ruby? I've read reports that Ruby is 5 times slower than Java.
 
Tug Wilson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We haven't done any benchmarking. However I would expect Groovy to be faster than JRuby today. JRuby is interpreted and we are compiled.

I expect both Groovy and JRuby's performance to improve in the future. We have done very little to optimise performance - we have been getting the subtleties of impedance free interfacing to Java right. The JRuby guys plan to generate bytecodes in the future.

Because Groovy leverages the huge set of Java libraries available you often find that the bulk of the time is spent inside a Java library so the performance of Groovy is not significant.
 
reply
    Bookmark Topic Watch Topic
  • New Topic