Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When to use Java when to use Groovy

 
Klaus Meucht
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no experiance with using a scripting language directly in Java.

If I mix java and groovy, doesn't it produce code that is really hard to detect duplicated code?

Can a code coverage tool like CLOVER, detect the coverage of Groovy code?
Makes it sense to use Groovy only for Test Classes and MockObjects and let the production code in plain java?

If a developer is not familiar in Groovy, how easy is it for him to understand the code?
 
Dierk König
author
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How do you detect duplicated code in Java? with PMD/CPD? This works well across Groovy and Java.

You can measure Groovy code coverage on source lines level, eg. with Cobertura. The book describes how.

Groovy makes sense for testing Java, but "only" would be far too limiting! ;-)

> If a developer is not familiar in Groovy, how easy is it for him to understand the code?

I don't know. Do you understand

println 'hi'

?

regards
Dierk
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dierk K�nig:

> If a developer is not familiar in Groovy, how easy is it for him to understand the code?

I don't know. Do you understand

println 'hi'

?


I don't think understanding println 'hi' is a fair assumption that Groovy is easy for a java developer to understand. Closures, for example, are proving difficult for me to wrap my head around since this isn't something that a typical Java developer might be familiar with.

But I do believe Groovy to be easier to understand as a Java developer than another scripting language all together (Ruby, Python, etc).
 
Dierk König
author
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code

new File('test.txt').eachLine { line -> println line }

uses a closure. Is it hard to understand?
I don't think so.

Of course, you can write any kind of code, code that is easy to understand and very complicated code in any language.

Groovy tries to build on the knowledge and perspective of a Java programmer. But of course to fully leverage its features you also have to learn. That's what the book is for.

ciao
Dierk
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, theorically I can use Java and Groovy interchangeably ?
Can I use Groovy completely to develope EGB ? (Enterprise GroovyBeans, inspired by Gregg's Gwing )
Or even to develope a framework like Hibernate, Tapestry or Spring ?
 
Tug Wilson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, theorically I can use Java and Groovy interchangeably ?
Can I use Groovy completely to develope EGB ? (Enterprise GroovyBeans, inspired by Gregg's Gwing )
Or even to develope a framework like Hibernate, Tapestry or Spring ?


Yes - We already have Groovelets (which are Groovy Sevlets) and GSPs (can you guess what they are? )
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GSPs (can you guess what they are? )

Global System for Positioning
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic