Why should I use jQuery instead of GWT? [closed]
Solution 1:
I would go with JQuery.
I once maintained a GWT project that eventually forced me to re-write it twice. First as a refactored GWT app, second in JQuery.
I haven't touched Javascript seriously for a very long time. The last time was about 2002. I'm a Java developer so my first impression of GWT was awesome. But that was just the impression.
Problems I found with GWT:
It forces you to follow its client/server structure. In the end all I want is AJAX and those good widgets. GWT's widgets by itself don't seem that good-looking. Aesthetically, I prefer Adobe Flex! But to keep the comparison closer, JQuery's UI looks better than GWT's. In addition you have that wonderful Theme Roller support from JQuery.
I've tried DWR. It's great. It's far easier to enable AJAX in your Java code using DWR than GWT.
If you're using GWT, eventually you will be forced to learn JavaScript. Arjen of SpringSource once said about XML and SOAP (though not the exact quote): "How can you develop WebServices and not know XML? SOAP is XML. You can't avoid it". Same thing with GWT. It's still Javascript in the end.
Realistically, Javascript isn't that hard to learn vs Java. More people know Javascript than Java. Even web designers know it. You're a programmer, and you're scared of Javascript?
Back to the project I rewrote. When I rewrote our GWT application it took me almost two months to rewrite it. With JQuery it took me two weeks, and I was rusty with JavaScript.
With JQuery you don't really write hardcorde JavaScript. That's why you use JQuery in the first place. Maintaining code with GWT is horrible. You wanna see the latest changes you did in the code... go compile... wait for GWT... 5 minutes... rinse... and repeat and hope it doesn't throw an error. If it does, you'll be recompiling again, and waiting for another 5 minutes. Rinse and repeat. With JQuery change a line, refresh your browser. Done.
I know I'm not being objective here, but I'm just sharing my experience :) The moral is don't be scared of Javascript. Google uses Javascript anyway
Solution 2:
I would suggest using GWT for teams with people who don't understand JavaScript but are (perhaps) more comfortable with Java. With GWT, you're likely to save yourself days if not weeks in compatibility testing, and will avoid a lot of common JavaScript pitfalls that people new to the language smash into. GWT also has great packaging features for CSS sprites, embedded data, and more.
However, if you know and understand JavaScript, I would use JavaScript, whatever your library of choice may be. Although I haven't had a chance to inspect GWT's generated code too closely, I saw some examples at Google I/O, and while it looked all candy and sparkles, you're likely create more elegant JavaScript code doing it the ol' fashioned way.
Solution 3:
If your group is most familiar with Java and you're planning on doing significant amounts of client-side functionality then you should at least evaluate GWT. The type safety, Eclipse debugging and shared code between the server-side/client-side will feel comfortable to your Java development team.
However, if your team is used to JavaScript programming with jQuery or another JavaScript library then it may be easier to stick to a technology that is pure JavaScript. GWT has a way of taking over large sections of the page, which is unfamiliar to most JavaScript developers. By take over the page I mean that typical GWT code likes to create its own DOM Elements instead of adding functionality to existing Elements on the page. This is why many GWT apps have a "loading..." screen when the page first loads. This isn't necessary, but it's the most common style of GWT development.
The fact that generated code comes out of GWT is less relevant for most GWT developers. GWT allows you to compile Java into something equivalent a normal java *.class file but in a JavaScript syntax that the web browser understands how to interpret. GWT acts much more like a compiler than a template-driven code generator. There are times that you will need to inspect the generated code but for the most part your debugging will be in Java via your Java debugger.
Another thing to think about is that regardless of the client-side technology you choose, your development team will need to be familiar with HTML, JavaScript, CSS and browser programming in general. GWT lets you write client-side code in a familiar Java environment but it doesn't hide the fact that you're working from within a browser.
Solution 4:
First of all comparing GWT with jQuery doesn't make much sense. While jQuery was build to make cross browser working with the DOM much easier, GWT is build to create large web applications.
So if you a bunch of static sides with some independent widgets, like calendar, slider and so on, jQuery is enough. If you want to build single page app, maybe with a large team, GWT is the better way. GWT has a lot well design architecture under the hood, especially the build in MVP pattern, UI-Binder templating system, i18n support etc.
So as JavaScript developer working more than year on a large GWT app, I would recommend never ever build a single page app only with jquery cause it wasn't build for. If you wanna use JavaScript take a look at backbone, spine, knockout or dojo.
Btw, as good the GWT architecture is build, you will have a lot of JAVA overhead. So if you project is growing, the time to compile your css and i18n properties will come annoying.