Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparison between GWT and Spring MVC

I was wondering if someone who was experienced in both technologies could give an objective comparison between the two, assuming you were building a complex web application that would be both very rich in on the server and in the browser.

One problem with the older paradigm, for me, is testability of the Spring MVC layer. I find that there's a lot of bugs that can creep into your application due to untestable annotations. This model also slows development cycles because you have to restart the server to make changes to the annotations/controller code... which is something I personally find very annoying.

I also don't want to deal with the complexity of javascript. Working with and testing an application all in Java sounds appealing to me. I don't really want to master another language, and learn all of its quirks, weird design decisions, idiosyncracies and the full history of browser incompatibilities.

So for a complex application, would GWT offer a superior approach? Are there any serious limitations to this approach over Spring MVC, which would probably be more flexible although harder to work with? Are there any gotchas and road blocks that are common for building complex applications?

I would really appreciate a comparison between the two. Please keep in mind that I have no experience with GWT, but about 10+ years experience with Spring. Thank you!

like image 394
egervari Avatar asked Oct 22 '11 08:10

egervari


2 Answers

The truth is that also GWT has a learning curve and also at least at the time I looked at it, two years ago, you're not doing much with the basic controls, you need external libraries and that means more learning.

After trying to learn GWT without much success, I opted for a webservice plus either jQuery or ExtJS, which also gives a very clean separation of the roles. I sat down and learnt JavaScript, it wasn't easy but it was immensely more fun than using GWT.

As for browser compatibility, once you use a modern library, you'll have very few of them. My code works in all browsers without too many problems, including IE 6. Also when I am too busy, I write the services only and outsource the JavaScript interface part, which allows increased productivity.

Anyway, this is fairly subjective, another person fluent with GWT, can have an opposite point of view of mine. I will anyway reject the following reasons:

  • ease of debugging. Not true anymore: it's very easy to debug JavaScript with FireBug, plus there won't be any business logic in JavaScript, only services call and display.
  • browser compatibility. There are very few quirks to remember, the most common one is that IE doesn't accept trailing commas in lists, which is anyway not in the standard, but Firefox tolerates them. Any modern JavaScript library will take care of compatibility for you.
  • Speed. To start with I will state that JavaScript is very fast for any reasonable computation within the browser. What is slower is DOM manipulation and of course anything involving the network, like AJAX calls. Your page will perform just right if you don't do design mistakes, like stuffing too many things or other problems that can arise when adding many elements directly to the DOM, instead of building your structure and then attaching it all at once.

As far as I can think now, the only valid reason is, I already know Java, I don't want to study another language.

As for your comment on Spring MVC. I am using Spring MVC and I don't feel the pain of restarting the server. The whole point of Spring is that everything should be easy to work with outside the container! In the Spring controllers I've very minimal code that just call the underlying services. What I need to unit test well are the services.

The controllers have very few code to test, I could just call them and test them within JUnit, but, at least for now, my approach is having a simple external test done through a web page with jQuery calls that check their response (it's not unit test, it's an integration test, but I feel there is a very little value to unit test a controller, if it's written properly).

like image 67
stivlo Avatar answered Sep 21 '22 06:09

stivlo


I am using GWT for more than a year now in a complex project (200 KLOC for the whole project), and I recommend you to give GWT a try.

In my opinion GWT is quite easy to learn, there are really good tutorials about how one should use this technology.

The advantage of using GWT is that one can build nice, fast, maintainable web apps, without knowing very little about browsers or javascript. You can also debug your client side code with a Java debugger and in complex apps this is huge.

Although GWT offers the possibility to properly unit test the client side code, this requires a good understanding of GWT's MVP paradigm and careful planning. If you mess up your code (which is not that hard, because GWT gives you total freedom) then you are going to end up losing this feature, but this is your fault, not GWT's.

like image 30
Zoltan Balazs Avatar answered Sep 23 '22 06:09

Zoltan Balazs