QCon 2007 Notes: Groovy Tutorial

Guillaume LaForge and John Wilson on Groovy and DSLs

  • Groovy is the dynamic language closely integrated with Java that sits on the JVM (book by Dierk Koenig, one of the committers).
  • Grails is the web application framework that uses Groovy to achieve convention over configuration (Book by Graeme Rocher, the project lead).
  • Scriptom is an optional Groovy module which lets you script ActiveX or COM Windows objects from within Groovy (e.g. Excel, Windows Media Player, Outlook).
  • JW: “I always think that Groovy’s like Java that’s smoked a bit of grass, really.”
  • There’s been quite a lot of work done on using Groovy to build and consume XML trees
  • Also a SWTBuilder (apparently a bit moribund, but should be easy to pick up and knock the dust off)
  • Operator overloading allows things like 30.euros + 15.euros, or 12.kilometres + 100.metres
  • Groovy date and time support, still experimental (in svn head):
    • 1.month is kept abstract-ish: it’s a duration until it touches a date, at which point it becomes a precise amount of time
    • arithmetic between durations is tricky because you don’t necessarily know how long they are
    • In Ruby, 1.month is a number of ms from the start: Groovy feels that their model (by which it’s an abstraction duration until it touches a date) is better
  • criteria builder neatly wraps Hibernate’s CriteriaBuilder
  • domain objects can have findBy injections that create Hibernate queries: no need for mapping files or hibernate.cfg.xml, groovy handles that automatically
  • the SpringBeanBuilder enables much nicer and more concise app definitions than an applicationContext.xml

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply