Getting Groovy (and Grails)

Explorations in Groovy and Grails Development

The Gr8 Conference: Building a Twitter Clone in Grails (or why Grails rocks!)

with 2 comments

The second day of the gr8 conference kicked off with a great presentation by Graeme Rocher on Building Twitter in Grails. Rather that giving a blow by blow of the presentation, you should check out a similar earlier presentation he gave yourself. The online presentation is close enough to the one Graeme gave to be better than my written notes. What I do want to do is comment very briefly about why I was so impressed by the presentation.

For anyone following languages and frameworks, it’s pretty easy to get jaded by all the “build an X in Y minutes” presentations. With a little bit of ORM and scaffolding, it’s pretty easy to write a framework that will let you build a simple blog in ten minutes with postings and comments (I wrote my own in two weeks in ColdFusion including extensible model and controller description in XML, a custom data mapper/baby-ORM and lightweight DI/IoC engine – it’s not a terribly hard problem to solve). What really stands out with Grails is that you can get a system with caching and a JMS message queue with transactional capabilities in under an hour!

As I mentioned in my recent GroovyMag article, the real differentiator for Grails (apart from the very simple learning curve for Java developers) is access to proven enterprise Java plumbing under the hood, with Groovy/Grails primarily being a “lipstick layer” to allow you to use Java frameworks without having to put up with the explicit configuration, static typing and lack of dynamic language features.

In an hour, Graeme demonstrated the creation of a simple Twitter client. He implemented a nice AJAX interface for posting and updated, implemented Security using the acegi plugin which wraps Spring (nee acegi) Security, added caching using ehcache, search (with the searchable plugin) using Lucene and Compass, JMS messaging for clearing the cache asynchronously with transactional integrity, and the capacity to access the page using .json or .xml file extensions and he even added a feed plugin to give you an rss feed in just a few lines of code!

Clearly any such demonstration is tied to the strengths of the framework being demonstrated, but it really showed me just how quickly you could mock up an enterprise style app that you could then just add richness to as required to (say) tie into legacy databases or more complex authentication systems. An incredibly impressive demonstration of a very compelling framework!

The sample code from the conference USB stick doesn’t quite work out of the box. You have to bootstrap a default role. In the grails-app/config/Bootstrap.groovy add:

def init = { servletContext ->
new Authority(authority:”ROLE_USER” , description:”Default User Role”).save()

and I’m also running into issues with null pointers for the twitter cache (conf/spring/resources.groovy – line 3: twitterCache(org.springframework.cache.ehcache.EhCacheFactoryBean))

however, I’ll have a look at this (I have a feeling anyone with Grails experience would figure this out in about 2 minutes, and I’m pretty sure I’ll be able to figure it out when I get a spare half hour to look at it – hopefully this weekend) and will post a slightly modified version of the code so anyone can download and play with the app. You *should* try this at home – it rocks! Kudos to Graeme & the Grails team!

About these ads

Written by peterbell

May 21, 2009 at 1:16 pm

Posted in gr8, Grails

2 Responses

Subscribe to comments with RSS.

  1. [...] a comment » After Graeme’s talk on building a Twitter clone in Grails, we took a short break and then returned to another presentation by Graeme – this time on the [...]

  2. [...] Last year I posted a fairly comprehensive series of articles on the blog (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) summarizing the content from Gr8 in Copenhagen. This year I opted instead to write [...]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: