• 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

Question for Mr. Davis

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Typing is optional in groovy correct? So does it attempt to derive type when compiling to byte code or is everything just Object?
 
Author
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Typing is optional in Groovy. If you care about the datatype, then specify the datatype. If you don't, don't. (I'm not being flippant -- honest!)



I tend to use types less when I am completely in Groovy, and use them more when I am talking to strongly typed things like Java and databases. But never forget that the types are still there -- we are on the JVM, after all.



In Java, you tend to do more polymorphic/interface-driven development. class Ipod implements Player -- that sort of thing. In Groovy, you can absolutely continue down that route -- Groovy class can implement Java interfaces and vice versa -- but pure Groovy development tends to be more about duck-typing. This means that I honestly don't care about the type of the class as long as it responds to my method call. This makes mocking and testing an order of magnitude easier, but that's a whole 'nother topic, isn't it? (grin)
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Bill]: Typing is optional in Groovy.

Which is a big win for programmers suffering from carpal tunnel, I'm sure. Scott (or "S" if you prefer ), can you tell us about the new telepathic interface-driven development techniques? You basically just think at the screen and the code appears, right?

OK, sorry, I just had to get that out of my system. Welcome to JavaRanch, Scott!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic