Monday, February 22, 2010

You dont know how lucky you are

Over the past 18 months ive been lucky enough to have almost exclusively been involved in projects developed with Grails. During this time I have seen a big change in my development style, I find myself focusing more on getting things done as opposed to figuring out how things work.

Today I kicked off a small consulting engagement with a client that is looking to productionise a prototype web application written with a mainstream Java web framework. Boy, what an eye opener! For the most part the application has been written well, but there is just so much of it. The scope of this application is lower than the Grails projects I have worked on, but the volume of code is grossly disproportionate. Thinking that this doesnt quite seem right I tried to apply some basic refactoring to the code, but soon gave up because I was just massaging valid application code. It honestly just seems to take a lot more Java code to get things done. I really am not wanting to unleash to much negativity on Java here, after all Java is within Groovys DNA. But I was just really surprised by the immediate contrast I noticed when switching back to Java after a sustained period of Groovy coding.

11 comments:

Michael Kimsal said...

This is what I've been saying about Java for *years*. There's massive amounts of boilerplate code (what others call 'high ceremony') and it's a huge turnoff for many people. As you said you end up spending a lot of time figuring out *how* to do things rather than just getting stuff done.

For someone who hasn't grown up with Java, but comes at it from another language (like perl or php, as I did), Java is simply too much, especially for web applications. Grails is the only thing which makes Java web development tolerable (and in many aspects, quite fun/interesting, but that's another story!).

The one-liner convenience functions of PHP greatly spoil you for brevity.

$x = file_get_contents("http://domain.com/path/to/rest/call");
or
echo date("m/d/y h:i:s A");
or
$unixtime = strtotime("+3 days"); or $time = strtotime("next Thursday");

Moving in to Java and realizing you have to figure out which libraries are necessary to import, then go learn some large API just to do what should be pretty simple things (then wait for a recompile just to see if it's worked) is off-putting to say the least.

Groovy and Grails are a strong step in the right direction by making it much easier to do the simple things with much less code (as you pointed out). Some of the PHP community are focusing on making frameworks which bring the complexity of Java to PHP, and Grails is focusing on bringing the simplicity of dynamic languages (like PHP and Python) to the Java world. It's interesting to see where these camps will evolve over time.

Sean Tindale said...

Wonderful comments Michael.

"high ceremony" is a very accurate term!

Michael Kimsal said...

I first heard it from Stuart Holloway - not sure if he coined the term or not, but I like to use it when I can.

Anonymous said...

The Grails stack is just crazy complex. As long as your app is simple and you don't hit bugs you might be right. But my experience with Grails let me to: either use Rails on JRuby or go back to java (if we are talking about framework for the JVM)

Anonymous said...

Java web development differs a lot. Grails' ORM technology GORM is not more convenient than JPA. Grails validation API has a nice Java EE counterpart called bean validation. A good web framework for complex GUIs would be Wicket. All that together would be a very good stack, that would allow to write compact and reusable code. But you have to do the integration first, which was already done with Grails.

dhaval said...

After spending many years in Java programming i have recently started learning Groovy and Grails and found Groovy more expressive compared to Java.

For one of our upcoming internet application i am proposing Grails whereas other members are resisting and proposing Spring MVC because of mature and wide community.

Are there any popular applications which i can use to present my views on Grails?

Anonymous said...

It is a thing that is self-imposed by Java developers. I found out after trying the Play framework. It is like Grails but I found it to be faster, more stable and easier to test.

Armando Flores Ibarra said...

What about Seam? It's pretty easy too !

I agree with Sean, great comments Michael !

Sean Tindale said...

Grails has become a lot stabler in the last couple of releases. Personally I don't find the Grails stack to be "crazy complex" unless I dive under the covers, which for 90% of web applications you don't need to do.

How could GORM be any more convenient? A GORM domain class is just a Groovy class dropped into a specifically named folder of a Grails project. No annotations, named queries etc... GORM even implements your most commonly used queries for you (finders etc..).

Sean Tindale said...

@dhaval

Check out the testimonials page of the Grails site for details of deployed Grails projects.

http://www.grails.org/Testimonials

The BSkyB site would be the largest implementation that I am aware of.

http://www.sky.com/

Dean Del Ponte said...

I've found Grails to be a joy to work with. It's not "crazy complex" and GORM makes Hibernate easy. Grails is the one framework I've used where I'm often pleasantly surprised by how easy many things are to do.

I've also recently delved into a Spring MVC app and, although it's better than a lot of Java frameworks out there, it's still a lot steeper learning curve than Grails.

Grails gets the win for ease of use and productivity.

Post a Comment