Where Groovy & Grails Breaks Down
First off, I do love Groovy & Grails. We’ve built a product with it: http://bounceoff.com. And I advise any dev shop that is Java focused to stop all development and switch immediately to G&G.
However, there are dirty little things that always ruin an otherwise perfect experience. This could be a very long post, detailing all of the tiny nits I have with Groovy & Grails. It wouldn’t be fun to write and it wouldn’t be fun to read.
Instead, I can encapsulate everything that is wrong with Groovy & Grails in one quick example. Take the markup builder in Groovy for example. Suppose I want to recreate this html:
<h1>Heading</h1> <p> <a href="mylink">Go here!</a> </p>
This is a very simple example. Let’s see how it looks in Groovy:
def html = new MarkupBuilder()
html.h1 "Heading"
html.p {
a(href:"mylink") "Go Here!"
}
Pretty straight forward right? Well, it would be if it worked! You see, you can set attributes of a tag with:
tagname(attributename:"attributevalue")
And the content of a tag with:
tagname "tag content"
But you can’t use them both at the same time! The first example doesn’t work! You have to use a hidden, UNDOCUMENTED ANYWHERE ON GROOVY.CODEHAUS.ORG namespace and method. Here is the working example (pay attention to line 5):
def html = new MarkupBuilder()
html.h1 "Heading"
html.p {
a(href:"mylink") {
mkp.yield("Go Here!")
}
}
And that, my friends, describes every single edge case scenario I have hit with Groovy & Grails. An obscure mkp namespace that contains a method yield handles the SPECIAL use case where I need both tag attributes and tag body content.
In other words, Groovy & Grails does quite a bit very, very well. Designed beautifully from a user-of-the-system’s perspective, you might say. And then BAM! You get slapped in the face with a complete shit-head-hack that was tacked on at the last minute in a fit of, “Oh… Fuck…! How are we going to handle THAT one?”
No comments yet, be the first.