views:

3046

answers:

10

I'm new to the web programming world, and I'm trying to learn about various Java MVC frameworks available. Through my research, I came across Spring MVC and Grails.

My question is: which one is better for developing enterprise web applications, or is there another option I haven't run across yet?

Important considerations:

  • Must be supported by Eclipse
  • Must have tutorials available online
  • Must have a good support community
  • The GUI in my project must be java-based
+4  A: 

There are many options you are missing like: Struts, JSF (Seam, MyFaces, IceFaces, Richfaces), Wicket, Stripes, GWT and many many MANY more...

I'd recommend you Spring MVC because as you are new into Web Development it would be easier to learn and (using your checklist):

  • It IS supported by Eclipse (check out SpringIDE)
  • The are tons of tutorials available online (I would start using the Spring MVC step by step)
  • It has great support of the community (better than Grails in my opinion)
  • Of course it's all Java
victor hugo
easier to learn than Grails? I seriously doubt it. Spring requires lots of configuration, if you are a newbie to both you are going to spend at least a couple of hours just trying to configure Spring.
Rodrigo Rivera
Yes but in the configuration are involved XMLs and POJOs, to learn Grails you must learn Groovy and other 'strange' stuff
victor hugo
please define "strange" stuff. Groovy is Java, there is no learning curve for a Java developer (I have never read a Groovy book and just know how to program Java, yet I am productive in Grails and have already 2 applications in production).
Rodrigo Rivera
+9  A: 

Grails is built upon Spring MVC since it's the underlying framework. Take a look at the following article also for more information on whether Grails is enterprise ready.

http://www.ibm.com/developerworks/java/library/j-grails12168/index.html

In theory I'd say yes there's no reason why you couldn't build an enterprise application with Grails. I think it's a better approach to learn initially, then fall back to learning Spring MVC for the other bits that you need - it is the same framework underneath.

Jon
I have to disagree - learning a new framework in addition to learning a new language is NOT a better approach (grails) versus learning just the MVC framework of choice (SpringMVC).
Rich Kroll
Err what? MVC framework of choice? I have to disagree with your poorly formed response. My point was that learning Grails is a better approach because it teaches you good practices, and so what - it's Groovy - not exactly a fundamental departure. Still a better choice...
Jon
@rich kroll: groovy isnt fundamentally different to java - its simple syntax differences, and whats more, you can type in valid java in a groovy file and have it compile and run. Its completely interchangeable. The point of grails is that it teaches web app development from a higher level, and so i would also recommend learning it.
Chii
A: 

We just moved to GWT just because having junior programmers developing front ends (combination of markup, styles and functionality) became such a major hustle lately. In GWT (gwt-ext) they have to stick to the toolkit and all the client stuff is generated for them. I know, I know - lots of "real" developers would scream bloody murder but in reality not having your developers to do "pixel perfect" and AJAX is simply priceless. Just as a site node for these who are willing to learn there is still ample opportunity in GWT to dork with HTML/CSS/JS

On a topic of Grails vs Spring MVC I vote the latter, just for a reason of most Java people being familiar with Spring framework in one way or the other

DroidIn.net
+2  A: 

Just a partial answer - but the Eclipse grails support is pretty horrific.

Pablojim
IntelliJ is pretty good.
duffymo
NetBeans supports Grails as well although I haven't tried it out.
cdmckay
SpringSource Tool Suite (http://www.springsource.com/products/sts) which is Eclipse based has support for Grails and makes this answer obsolete.
Pascal Thivent
Even with STS eclipse support is still very poor. Certainly nowhere near IntelliJ
Pablojim
+7  A: 

I've recently made the switch from Spring development to Grails and I like Grails quite a bit. However, part of what makes Grails impressive is how quickly you can get stuff up and running, which is really fast as long as the plugins you need are available. We've struggled a bit where I work and my boss has questioned whether it was a good move to go to Grails and while there still is a bit of a learning curve and time commitment to build the plugins you'll need for your application (we had to port some things) I can say it's totally worth the effort. Development is much faster once you get all your groundwork stuff in place (which we're still working on).

The Eclipse support for Grails is still lacking though at this point, and I've switched back to Netbeans (if free is the concern) which seems to be doing a better job at keeping up with integrating tools.

Since Grails is built on Spring, you can wire in parts of Grails to your Spring app if you feel like it. I see a lot of blurring lines between Spring and Grails which makes it harder to say which one to go for without knowing background on a particular application.

In general, if you have no experience in either and your application is green field, I'd say pick Grails. If you have experience in Spring (but not Grails) and a legacy application, then you have to decide if you can afford the migration time, after which you will probably benefit from reduced development time, but might be tough to justify in the short term.

Community support is growing by the day and between Nabble and here, you should be able to get whatever help you need. There are a smattering of tutorials available as well and the documentation is pretty good. I'm confused on the GUI needing to be Java though, since I'm guessing the GUI will actually be HTML based (and not an applet).

tgm
Sorry for the ambiguity, the specs on the project are a bit ambiguous as well. The GUI back-end must be java based, while the java code would generate the html web forms.
bkritzer
On a side note, if resume skills are important (looking at future employment in the near term) it might be better to go with Spring since Grails is still probably considered leading edge and not mainstream. And from talking with my consulting contacts there are lots of Spring opportunities and not so many Grails yet. But I would definitely anticipate more and more companies switching to Grails as developers get exposed to it.
tgm
@bkritzer: GUI backends? as in, the project has two user interfaces - a thick client GUI, and also a browser based GUI? If so, check out griffon http://griffon.codehaus.org/ - its a GUI framework that follows the philosophy of grails.
Chii
+13  A: 

Hi,

6 Months ago I was in the same situation. I was new to both web development in the JVM and with no experience whatsoever with Grails or Spring. I first tried Spring with Intellij Idea, the problem was that I spend lots of hours just trying to get my environment configured, it was really complicated and finally I gave up.

Grails was so easy even if I had no experience with Groovy (it is almost the same as Java but with less overhead). When I started learning Grails there were few resources available (the best ones are The Definitive Guide to Grails Second Edition and Grails in Action) and the release was not as stable as it is now. However, it was easier to learn and required no configuration whatsoever.

Grails is Spring + Hibernate + Sitemesh and if you need a Java or Spring feature you can always add it.

Must be supported by Eclipse -> It is supported by Eclipse, but I prefer IntelliJ Idea or even Netbeans.

Must have tutorials available online -> The tutorial from the IBM Developer Networks are a great way to start. http://www.grailstutorials.com is also a great resource. However, if you are serious about learning Grails you should buy one of the books I mentioned above (The Definitive Guide to Grails Second Edition or Grails in Action).

Must have a good support community -> The Grails community is one of the most helpful community I have ever seen. Almost always Grails authorities such as Gramme Rocher answer directly your question and provide helpful insight (do not forget, that most users are new to Grails, so there are no dumb questions or the newbies are bullied by the pros like in other communities).

The GUI in my project must be java-based -> Grails has support for multiple views such as GWT, Flex, etc. Lets not forget that Groovy IS Java.

Grails is enteprise ready (just look at the list of projects using Grails and you will find known names such as Sky), because it is built on the shoulder of giants but helps you deal with the cumbersome configuration of Spring and Hibernate.

Try Grails, you will not regret and you will be writing production code in less than a couple of hours. (Another important plus about Grails, you do not need to compile and restart the server if you make minor changes to your code, when you reload your browser the changes are already there! Therefore, you get the same productivity feeling of technologies such as Ruby on Rails).

Rodrigo Rivera
+1  A: 

Hi! I have to agree with Rodrigo. I was new to web programming and first tried spring MVC. I could not get the configuration right even for a very simple application.

I then tried grails, just a few days later I had already built up a fairly complex web application with no pain at all. And groovy is very simple for a Java person. Much simpler than to understand all XML files in Spring. Just avoid every software that exposes xml to the end user and you will be happy.

Grails = no XML = no pain.

alebo611
+1  A: 

Grails is simply awesome. Its just incomparable to any other framework. I'll recommend it to every new developer who is yet to start with any application framework. Its so easy that you can create a live page in just 5 minutes max and that alongwith all the DB transaction n all taken care of internaly.

Amit Rangra
+1  A: 

Another possible option is Spring Roo It's still in the fairly early stages of development but what's available is usable. It's basically a code generator that generates all the configuration and scaffolding for a Spring MVC application. This allows you to use standard Spring and Java code while avoiding writing configuration files by hand. I've found the forums are helpful and you can get your questions answered fairly quickly. Depending on your project this may be an option, especially if it's a project you can afford to use newer technology on. For a Spring Roo tutorial see http://blog.springsource.com/2009/05/27/roo-part-2/

Jared
A: 

I have done project using grails. If you think JSF, JSP, Struts, Spring don't have grails create-app, grails generate-all and so you have considered grails as your primary development framework think it twice before you start developing in grails. At first it seems grails generates lots of code that does not need to be written or even remember, but lots of your time will be lost in accumulating codes from different views to one, different controllers to one and so one. Grails can even make you forget transaction(Services may not seem important at all). You may loose focus from writing lots of business logic code other than CRUD. All your business logic may end up in the controller(which is even not a clear code design). You will even try to use the default look and feel from grails plug-ins (navigation, css). If you see the under lying problem generated from all of this is that grails takes your focus away from developing large enterprise application. Gives you fast result, but if you don't do it with 10 times greater planning than a normal J2EE application you will end up in a deadlock. Bottom line is with simple planning a Spring project can add problems additive ways whereas grails can add them exponentially. But if you know J2EE well, and you implement all the standards in an intelligent way, grails projects can be more fun than anything else. But till now none of the book of grails have considered design and development as their primary focus. All the authors consider user to be already a perfect J2EE application developer. If you learn grails you get a flood of plug-ins. Every thing that worked in Java is still 100% usable with grails. My suggestion is, if you don't have good J2EE background grails in not the first option. Sky.com had experienced J2EE developer so they found grails easy.

razorxpress