• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

When to use Java when to use Groovy

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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 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
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

GSPs (can you guess what they are? )


Global System for Positioning
 
What? What, what, what? What what tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic