Skip to: Site menu | Main content

Groovy 

      Download | Documentation | Developers | Community

An agile dynamic language for the Java Platform

Differences from Ruby Add comment to Wiki View in Wiki Edit Wiki page Printable Version

The core abstract programming model of Ruby and Groovy are very similar: everything is an object, there is a MOP in control of all activity, and closures are the core structuring tool after classes. Ruby uses the Ruby library, Groovy uses the Java library with some additions of its own. This is the biggest difference but it is a huge difference. Syntactically, things like:

File.open( 'blah' ) { | file | puts( file.read ) }

becomes:

println ( new File ( 'blah' ).text )

which doesn't show that the Groovy closures syntax is:

{ file -> doSomething ( file ) }

which is slightly different from Ruby, but does show that sometimes Groovy has a different approach to certain things compared to Ruby. So in moving from Ruby to Groovy, there are gotchas.