Why I’m not using Groovy at work

Posted on December 14, 2009. Filed under: Grails, Groovy, Uncategorized | Tags: , , |

A disclaimer: this blog is based on my personal failures with getting Grails accepted in our company. So, no, this is not the holy grail into dropping your EJB, Struts or Java toolkit to get groovy with Grails, but maybe you can learn something on how NOT to do it, and post some comments on your experience.

Introduction
2.5 Years ago, I got my first cup of Grails. It was some time before the Groovy/Grails Exchange 2007, which I visited consecutively. As a result of that visit, I had Graeme Rocher over to our company to give a presentation about Grails (almost 0.4 at that time), and I expected the rest to follow naturally (the rest being: drop all our Java development and take up Grails for all of our web development). I was a little naive in that, I experienced the couple of months after that. Not even did we not drop all our Java development: we dropped none, nor did we picked up any of the cool features Groovy or Grails offered. Instead, people went crazy with frameworks like Wicket, SEAM and other cool stuff, like..ehh…EJB’s…

However, in my spare time I never left Grails and I used it for a lot of prototype applications, especially because the ease of setting up a complete project with Spring/Hibernate integration, etc. And also because it’s just fun to use the power the Grails framework harnesses. Anyway, I never could convince people to seriously use it. I inspired some people to use it, but only for short periods. The lack of IDE support didn’t help in that, and with the thousands of frameworks around, you’ve got to make a choice somewhere. However, I haven’t given up on Grails, and I still try to use it as much as possible. So, when I started for myself in April as an independent (though I do favor certain technologies!) consultant, I thought: this is my chance! I can now focus on Grails technologies. However, even though I’m not quite inexperienced with Grails, I found it hard to find a good (well, any actually) project which was open to Grails, so I found a different project, in which I could focus on other things (like ATDD/TDD, XP, and other quality related things).

However, then, all of a sudden my manager showed some interest in Grails (might not be the best reason to use Grails btw, but it’s great that this is without any resistance!), and we decided to take on a project in Grails. There, the problems started. (Note: I don’t blame anyone in this, except myself: I should have used a different approach. That’s part of reason for writing this blog, to prevent you from making the same mistakes).

What I did first, was tell a little bit about Grails to explain the team how Grails works. That was actually my first mistake. I should have told them lots, lots, a little more, and everything again after that. I thought the transition would be easy, but they were struggling with the framework and the language. I didn’t expect this, to be honest. My expectation (and experience) is that Grails is easy to start with. Get a book, read the documentation, and your ready to go. We built a good prototype, got great feedback on it! However, the old habit kicked in.

Building Grails
First, we tried to build our Grails application with Maven. Bad idea, since it caused some nasty challenges, like getting the code coverage to appear, and getting come quality metrics with tools like CodeNarc. However, you’ll still have to do your (transitive?) dependency management, releasing of software, reports, etc, so there’s something to say for using Maven. It didn’t quite work for us, however, and we spent quite some time into bending it into something which worked for us, which failed. I still haven’t found a viable alternative to Maven. Gradle is nice, Ivy + Ant/Gant seem okay, but that’s not nowhere near the power (I wouldn’t say flexibility) I got with using Maven. I do not, however, make this a Maven vs Whatever Build Tool discussion. I just happen to like Maven for it’s reports, plugin integration, dependency support and modular structure.

Team
Then I also had to overcome the resistance of some of our team members to dynamic languages. Some people prefer the (fake, IMO) safety a statically typed language provides with it’s compilation process. Well, there’s no helping you if you do an Integer.parseInt(“abc”) in your Java code: it will fail just as badly. At runtime. That’s why we write tests, to cover cases like this. This is true for Java, and it’s just as true for Groovy. However, there was still a lot of FUD about Groovy’s usage in bigger projects regarding refactoring, tool support, and even performance. Well, to be honest: I have no idea how easy it is to refactor Groovy code, but, with less code to write, there’s less to refactor. While this might be a bit short sighted, I feel it holds true for a lot of cases.

IDE
The tool support deserves a paragraph on it’s own. Eclipse + Groovy was not a good combination. At all. It was bad, worse, and even a bit worse than that. Even if you are the genius to get it to work (or would I say madmen, since a genius would choose a tool like NetBean or IntelliJ, or, heck, TextMate), you still wouldn’t be able to run a decent unit test in it. Did I mention refactoring? I didn’t, for a good reason: No Support For Refactoring. Let me rephrase that: No Support For Refactoring… in Eclipse. Then why choose Eclipse, and not a great tool like IntelliJ (I’m referring to the 8 release) or NetBeans you might ask. To be honest: I have no idea. I don’t use Eclipse. I’ve used IntelliJ for the last 5 years, and only recently I’m switching to SpringSource Tool Suite because of JetBrains’ ridiculous decision to not show module dependencies in the project view. I hope they get some rest after the release of IntelliJ 9, and see the light to put it back in. Until that period, STS is a really good substitute, and has excellent Groovy and Grails support, which is getting better each day!

The right approach?
So, if I would introduce Groovy or Grails again at my work, I would:
– Pick the right people. People who are not intimidated by a dynamic language, but who have the discipline to use it right.
– Pick the right people. People who are prepared to make a switch. To switch from IDE, switch from build tool, switch from language.
– Pick the right people. People who have the mentality to make it work, overcome challenges and share their findings.

Conclusion
It wasn’t intentional to put ‘Pick the right people’ there, but I think that this is the critical factor to make it work. Make it work from within the team, and make it work from outside of the team (IT operations, Management, etc). I’m looking forward into hearing your responses to this. I hope it doesn’t sound to bitter, cause I’m not. I just made the wrong choices with a partially not-suitable team. It’s my mistake, and I don’t blame anyone but me. I just hope people can learn from my experiences, and the post from Marc Palmer was just the right incentive to finish this post. I hope it helps!

Read Full Post | Make a Comment ( 12 so far )

The First NLGUG Meetup

Posted on May 16, 2009. Filed under: NLGUG | Tags: , , , , |

On the 7th of May, we had our first NLGUG Groovy an Grails meetup. In one word: it was great!

Normally, when I organize something (be it a motorcycling event, going to the movies, or anything else), of all the people who said ‘yes’, 30% will show up (that is, if I’m lucky). Since 12 people expressed that they would attend the first meetup, I expected a group no bigger than 5 people to show up. You can imagine my surprise when out of 12 people, 18 showed up! That’s 150% more than you might have expected, and 500% more than I expected!

The event was kindly hosted by Lunatech Research BV, a small company in Rotterdam, who wanted to impress us with their office and hospitality. That succeeded greatly in that! The office was great, and the snacks where snacks++ ! Really well done, again: thanks for hosting the event!

The plan was to have 2 small sessions (of around 50 minutes each), drink some beer, get to know each other a little, etc. I think it worked out pretty well. We started with a introduction round, and it became apparent quite quickly that not a lot of people really (that is: in production) something with Groovy and Grails. Out of 18 people, only 2 people had real life experience with Grails. While I certainly hope this will increase, this is a really nice baseline. There were quite some members who had something in the pipeline, but nothing to concrete yet.
After our round of introduction, I had a small talk about how Flex, Grails and JMS could be combined into a small chat application. I thought it was a nice application, but due to time constraints, my presentation could have been better… Well, hopefully I’ll have some more preparation time next time!
The second presentation, which was presented by Michel Vollebregt, was great! The presentation described how to use Groovy DSLs, and was a great combination of combining Java + Groovy to create a very readable (at least: from a user perspective) language to calculate savings over the years. A really nice presentation with live coding, which deserves a lot of extra credits, IMO.

All in all, I think the whole evening was great. I’ve met a lot of new people who were all equally enthousiastic about G&G, and I heard a lot of great feedback about the evening. I think it was a big succes, and I’m looking forward to our next meetup in a month or two, which will be hosted by VX company this time. Great work guys!!!

Read Full Post | Make a Comment ( None so far )

Dutch Groovy and Grails User Group

Posted on March 16, 2009. Filed under: NLGUG | Tags: , , , , |

At the moment, I’m busy reviving the Dutch Groovy and Grails User Group. The goal is to meet other local Groovy and Grails developers to talk about code, architecture, and lots of innovation. Both beginners and pros are ofcourse welcome!

I’ve already planned the first event, at (probably) May the 1st, which is viewable here

This evening will be an opportunity for software developers to meet people with different experience levels with the language and the framework. It will also be a good way to identify how to help your and other companies by using Grails. The program isn’t carved in stone yet, but if you have some suggestion, let me know!

Furthermore, I’ve setup an Linkedin group, to get an indication of the interest in Groovy and Grails in the Netherlands. You can join that group here.

So I hope you can help me make this a great succes, and let the Dutch GG community have a voice in the Netherlands!

I’m really dedicated to make this work, but I need your help! It would therefor be great if you could all join, so we can organize some interesting session.

Read Full Post | Make a Comment ( None so far )

Converting Groovy Objects to JSON using Grails

Posted on February 14, 2009. Filed under: Grails, Groovy, Uncategorized | Tags: , , , |

Disclaimer: this might not be the best way to do it. I’m open for improvements, but it’s a way I’m using now, and it works pretty nice!

Currenly, I’m creating an application which does some JSON communication. Since Grails already has nice support for JSON, I wanted to reuse their libraries, but, at the moment, I don’t need a complete web Grails application. So, the plan was to reuse the JSON (deep) converters to convert my Groovy classes to JSON, and work with that. I created the following small test to try to accomplish what I wanted:


import grails.converters.JSON

class Person {
String name = "erik"
int age = 10
}

println new JSON(new Person()).toString()

Well, I don’t think I’d be writing this blog entry if things were really this easy. Executing the above code fails with a nasty NullPointerException:

Caught: org.apache.commons.lang.UnhandledException: java.lang.NullPointerException
	at testjson.run(testjson.groovy:10)
	at testjson.main(testjson.groovy)

Why is this, you might ask. Well, it turns out the JSON converter is using a ConverterUtil class, which expects a GrailsApplication. When there’s no GrailsApplication, the code will fail with a NPE as a result. If you’d like to see this fixed: I’ve created a JIRA issue here.

However, I did came up with a workaround. It’s not perfect, but it works. Since the ConvertUtil is a sort of Singleton, you call it yourself, and set a DummyGrailsApplication instead. Well, instead of the dummy version, we can use a DefaultGrailsApplication instead. So, after our fix, the code looks like this:


import grails.converters.JSON
import org.codehaus.groovy.grails.commons.DefaultGrailsApplication
import org.codehaus.groovy.grails.web.converters.ConverterUtil

class Person {
String name = "erik"
int age = 10
}
ConverterUtil.getInstance().grailsApplication = new DefaultGrailsApplication()
println new JSON(new Person()).toString()

When running this, the following output is produced:

{"age":10,"class":"Person","name":"erik"}

Which is exactly what we want!

Read Full Post | Make a Comment ( 4 so far )

IntelliJ JSON Formatter Plugin 0.2

Posted on February 14, 2009. Filed under: IntelliJ JSON Formatter Plugin | Tags: , , , |

I’ve worked with my JSON Formatter plugin for a couple of days now to debug my Grails communication layer, and even though I created it myself, I want to say that I’m quite pleased with it. The only thing which annoyed me a bit is that it’s hard to see  if the JSON code is valid. Well, while it’s not 100% complete (and correct) yet, I’m happy to say that I’ve added simple validation to the Plugin, thanks to the JSON library of Bruno Ranschaert, who was quick to respond to a small bug in the ANTLR part of the JSON library. Since that’s fixed now, you can use the JSON plugin to further enjoy Grails and IntelliJ development! 🙂 (See the pictures for the feedback panel!)

picture-4

Read Full Post | Make a Comment ( None so far )

IntelliJ JSON Formatter Plugin

Posted on February 5, 2009. Filed under: Grails, IntelliJ JSON Formatter Plugin | Tags: , , , , , |

I’ve just created my first IntelliJ plugin, a JSON formatter. Since I work a lot with Groovy and Grails, and Grails supports JSON so nicely, it’s sometimes necessary to debug the JSON code going back and from the client to the Grails backend. However, since the JSON code is stripped from whitespaces, it’s a bit harder to read than a nested structure. To format the JSON, you can use various websites , but it requires a context switch (from IDE to Webbrowser), plus it requires an Internet connection. To solve this, I created an IntelliJ JSON Formatter plugin, which nicely hooks into IntelliJ. To give you an idea of what the plugin looks like, please take a look at the following image:

IntelliJ JSON Formatter plugin

This images gives an impression of a formatted piece of JSON code, and also includes brace matching and coloring thanks to the RSyntaxTextArea. The JSON code is parsed with the help of the JSON tools from Berlios.

You can install the plugin by using IntelliJ’s integrated plugin manager. If you’ve used it, please give me some feedback! I’d like it!

Read Full Post | Make a Comment ( 11 so far )

Liked it here?
Why not try sites on the blogroll...