• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

groovy vs grails

 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May i know the difference between Groovy and grails.

and how the groovy and grails can be compared with java. is these technologies are alternative to Java,j2ee???

many i know more on this.

many thanks in advance,
rahul.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, there is no "vs" in that equation.

Grails is a web framework from front end to back, Groovy is a "language" that Grails uses. Grails also has GORM which uses Hibernate, and Grails also uses Spring MVC and Spring Framework. You can add lots of different plugins to Grails to use other technologies and get other features, like plugin for acegi security which is Spring security.

Groovy is a scripting type language that is very close to Java, but adds features that Java doesn't have like closures and mix-ins

The code you write in Groovy is a quite a bit less than Java, you don't hvae to import any java.util class, you don't need any semicolons.

You still use Java in Groovy, but it is slightly different. Like I said Groovy makes Java coding easier.

Mark
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,

There's a good introductory video on Grails at: http://www.infoq.com/presentations/Grails-For-Spring-Developers

As Mark says, Groovy/Grails is like Ruby/Rails i.e. Grails is a web application development framework implemented in Groovy, on top of lots of JEE stuff (Spring, Hibernate etc). It's designed for the JEE platform and the standard Grails download includes everything you need to get started i.e. all the Java libraries, Groovy and a Tomcat or Jetty servlet engine. Your Grails web application can be deployed as a WAR on any JEE server, just like any other JEE web app. You can mix in Java code in your Grails application (as with any other Groovy application), or drop down to Hibernate level etc if you think it's necessary e.g. for integrating legacy DB stuff. In short, Grails makes JEE development fun again.

Groovy is independent of Grails i.e. you can install Groovy without ever using Grails. Groovy code runs in the JVM and you can use any Java classes in your Groovy scripts, so it allows you to combine existing/legacy Java code or standard Java libraries with new Groovy code in whichever way you like. Groovy typically requires far fewer lines of code than Java for many tasks. Examples: http://groovy.codehaus.org/Cookbook+Examples

Book tip: "Programming Groovy" by Venkat Subramaniam is pretty good and fairly up to date.

Also, there's supposed to be a new updated edition soon of "Groovy in Action" by Dierk Koenig, which will definitely be worth getting when it comes out. Groovy has developed quite quickly in recent years, so older books may not cover everything you can do with Groovy.

Chris

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic