Enterprise Java

GWT – Pros and Cons

I love JavaScript. With the advent of jQuery and Mootools, my love for JavaScript has only increased plenty-fold. Given a choice I would use either of the aforementioned frameworks for any web application I develop. But being in the service industry, time and again I have to succumb to the client’s pressure and work in their choice of technology – whether or not it is the right one (The one who pays the piper calls the tune. Isn’t it?). One such client exposed me to the world of GWT.

I have given GWT a shot couple of years back on the day it was released. I didn’t like it that much then, so I dismissed it and never returned back. But, over the past six months working on this project I have a slightly different impression on this framework. I still cannot say that GWT is the next big thing since sliced bread, but at least it is not as bad as I thought it was. I have just documented my observations, both good and bad during the course of this project and thought some fellow developer might find it useful while evaluating GWT.

Pros:

  1. If you are a Java veteran with experience in Swing or AWT, then choosing GWT should be a no-brainer. The learning curve is the least with this background.
  2. Even if you are not experienced in Java GUI development, the experience in working on server-side Java for years will come in handy while developing GWT apps
  3. You can create highly responsive web applications with heavy lifting on the client-side and reduced chattiness with the server-side
  4. Although there are numerous JavaScript libraries out in the wild and most of them are worth their salt, many conventional developers don’t understand its true power. Remember, a powerful language like JavaScript is a double-edged sword. If you don’t know how to use it, even you won’t be able to clean the mess you create
  5. You can migrate from a typical web application to a GWT application iteratively. It is not an all or nothing proposition. You can use a clever trick called JSNI to interact with loads of JavaScript functions you already possess. But it is always better to move them to GWT sooner rather than later
  6. The IDE support for GWT cannot be better. Java IDEs have matured over the past decade to be one of the best in the world and GWT can take direct advantage of it
  7. The integrated debugging beauty is something you can kill for. The excellent debugging support offered by the mature Java IDEs is one feature that could sway anybody’s decision in favor of GWT
  8. The built-in IDE support to refactor Java code can directly be put to good use to maintain a simple design at all times. Doing this in JavaScript is not for the faint at heart
  9. The IDE syntax highlighting, error checking, code completion shortcuts etc are overwhelming – to say the least
  10. GWT is being actively developed by Google. We know that the project is not going to die off anytime soon. Until now their commitment towards the project says a lot about its future in the industry.
  11. The community behind the project is also a big PLUS. Discussions take place daily in Stack overflow, discussion forums, wikis and personal blogs. A simple search with the right keyword could point you in the right direction
  12. GWT is a well thought-out API; not something that was put together in a hurry. This helps you as a developer to quickly comprehend the abstractions and makes it really intuitive to use
  13. You can use GWT’s built-in protocol to transfer data between the client and the server without any additional knowledge of how the data is packaged and sent. If you prefer more control, you can always use XML, JSON or another proprietary format of your choice. Even in that case, while using JSON, you don’t have to use an non-intuitive java JSON library. You can use JSNI to ‘eval’ the JSON using straight javascript. Cool huh!
  14. You have the advantage of being able to use standard Java static code analyzers like FindBugs, CheckStyle, Detangler, PMD etc to monitor code and design quality. This is very important when you are working in a big team with varying experience.
  15. You can use JUnit or Test NG for unit testing and JMock or another mock library for mocking dependencies. Following TDD is straight-forward if you already practice it. Although there are JavaScript based unit testing frameworks like jsunit and qunit, come on tell me how many people already know that or are itching to use that.
  16. The GWT compiler generates cross-browser JavaScript code. Today, any marketing person who says this will probably be beaten. It has now become a basic necessity, not a luxury
  17. The GWT compiler optimizes the generated code, removes dead code and even obfuscates the JavaScript for you all in one shot
  18. Although the compilation process takes hell a lot of time, you don’t have to go through that during development. There is a special hosted mode that uses a browser plug-in and direct java byte-code to produce output. That is one of the main reasons you are able to use a Java debugger to debug client side code.
  19. Rich third-party controls are available through quite a few projects like Smart GWT, Ext GWT etc. They are well designed, easy to use and theme-able. So, if you have a requirement where existing controls don’t just cut it, you should be looking into one of these projects. There is a really fat chance that one of those components will work out. Even if that doesn’t work out, you can always roll out your own.
  20. GWT emphasizes the concept of a stateful client and a stateless server. This results in extremely less load on the server where many users have to co-exist and high load on the client where only one user is working
  21. I18N and L10N are pretty straight-forward with GWT. In fact locale based compilation is taken care by the GWT compiler itself. The same cannot be said about regular client-only frameworks
  22. GWT comes built-in with browser back button support even while using AJAX. If you are an AJAX developer, I can almost feel your relief. This is priceless.

Cons:

  1. GWT is a fast developing project. So, there are a lot of versions floating around. Many functions, interfaces and events get deprecated and keeping up with their pace is not too much fun when you have other work to do
  2. There were quite a few GWT books during the beginning. Not so much these days. For example, I haven’t found many books on the 2.0 version of GWT. This leaves us only with Google’s documentation. I agree that the documentation is good and all, but nothing can beat a well written book
  3. GWT is not fun to work with. After all it is Java and Java is not a fun language to work with. If you add the fact that entire layouts and custom controls should be created in java, you can easily make a grown programmer cry. With the introduction of UI binder starting version 2.0, that problem is kind of solved, but now you have a new syntax to learn.
  4. The Java to JavaScript compilation is fairly slow, which is a significant con if you choose GWT.
  5. I personally prefer defining structure in HTML and styling it using CSS. The concepts used in HTML are clean and straight-forward and I have years of experience doing just that. But in GWT, I am kind of forced to use proprietary methods to do the same. That combined with the fact that GWT doesn’t solve the styling and alignment incompatibilies for me compounds the problem. So, writing layout code in GWT is something I despice. But with UI Binder and HTMLLayout from version 2.0 onwards, I feel I am back in my own territory
  6. It requires some serious commitment levels to get into GWT, coz, after that, a change in client side technology could require a complete rewrite of your app, as it is a radically different approach than other client side frameworks
  7. There is not a defined way to approach an application development using GWT. Should we use only module per app or one module per page or somewhere in between. These design patterns are slowly evolving only now. So, typically people tend to develop all in one module until the module size goes beyond being acceptable and then they refactor it into multiple modules. But if it is too late, then refactoring could not be that easy either
  8. Mixing presentation and code doesn’t sound right although typical desktop GUI applications does just that. But these days, even desktop application frameworks like Flex and Silverlight have taken an XML based declarative approach to separate presentation from logic. I think GWT 1.x version had this disadvantage. With the introduction of UI Binder starting from version 2.0, I think this disadvantage can be written off although it is yet another painful XML language to learn
  9. You would often be punching in 3X to 5X more code than you would with other client libraries – like jQuery – to get simple things done
  10. You should also remember that with GWT, the abstraction away from HTML isn’t complete. You’ll still need to understand the DOM structure your app is generating in order to style it, and GWT can make it harder to see this structure in the code.
  11. GWT is an advantage only for Java developers. Developers with .NET or PHP background won’t gain anything here
  12. If you have tasted the power of JavaScript and know how to properly utilize it to your advantage, then you will feel crippled with an unexpressive language like Java

I am sure many of you will have differences of opinion. Difference is good. So, if you think otherwise, feel free to leave a comment. We’ll discuss…

References:  GWT – Pros and Cons from our JCG partner Ganeshji Marwaha at the Ganesh blog.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

35 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Emilio Bravo
Emilio Bravo
12 years ago

About Cons: 1 “Many functions, interfaces and events get deprecated”, as in any other framework or toolkit 2 ok, but the documentation is quite worked 3 and 5, uibinder, xml layout (you can use html layout). 4 which version of GWT you tried it?, the compilation is only required at the end of development process. 6 ok 7 which version of GWT you tried it? you can use MVP. 8 uibinder, xml layout 9 to simple things, use jquery. 10 uibinder, xml layout. 11 y 12 Gwt compiler generates optimized javascript for all web browsers including mobile. The javascript code has no dependencies on external libraries that have… Read more »

Vijay Nathani
Vijay Nathani
12 years ago

A new language Dart is available (at least in beta form). It removes browser incompatibilities. It allows us to continue using HTML and CSS. The language is familiar to Java and C# developers. I hope someone does a detailed comparison between GWT and Dart.

Steve Paul
Steve Paul
12 years ago
Reply to  Vijay Nathani

In terms of using GWT, I like the idea that AJAX is used and that entirely new html pages are not ‘published’ on the server-side. This is not only much more performant, but obliges less html coding and avoids the complexity of MVC frameworks. The only reason MVC emerged is because developers are being forced to communicate with a user by publishing and posting new server pages. This is little better than paging through a book. What actually should be happening is that the server should be communicating to the interface, and the interface should be responsible for rendering the… Read more »

kamoliddinov
kamoliddinov
12 years ago

If someone .net or php even they can use gwt, gwt is js, i created projects with gwt and php. Gwt asks php server to get data and represents it in html. 

Andre Dölger
Andre Dölger
12 years ago

“GWT is being actively developed by Google.” – I’m not really sure if this is true. It seems to me that a lot of GWT developers of Google moved to project “Dart”.

Adisesha Reddy Gaddam
Adisesha Reddy Gaddam
12 years ago

Java developer for 9 years and used GWT for 2 years.Recently we started the project in GWT and rewrote everything in JavaScript after 3 months of work.As you mentioned, it is good for Java developers who do not want to get into non senses of JavaScript or not learn other language. Remember the native language of browser is JavaScript and learn to communicate  in that language. If your life depends on it, do you use Google Translate to communicate or learn the language?  1. It is a myth that you do not need to know JavaScript if you do it in… Read more »

Emilio Bravo
Emilio Bravo
12 years ago

“Recently we started the project in GWT and rewrote everything in JavaScript after 3 months of work”, Why did you have to rewrite the code? ” You must know the JavaScript in order to debug them.Also how do you know if it is not a bug in GWT generated js?”, How do you know if there is an error in the javascript implementation of the browser or java bytecode or even in assembler code?, gwt compiler generates optimized code for each browser and abstracts you from many problems in javascript.”I have seen code where components and panels are added, on top of each… Read more »

Adisesha Reddy Gaddam
Adisesha Reddy Gaddam
12 years ago
Reply to  Emilio Bravo

@google-f4c273255cbecc45ebe2de2005d3c401:disqus   ‘Why did you have to rewrite the code?’  I think this blog and the points I mentioned already answers that. Now we do not have this scenario, http://xkcd.com/303/ ‘How do you know if there is an error in the javascript implementation of the browser or java bytecode or even in assembler code?, gwt compiler generates optimized code for each browser and abstracts you from many problems in javascript ‘ I know somebody will come back with this point. It depends on your trust level and number of active users. More the number of user, more easy to find solution. I do not… Read more »

Emilio Bravo
Emilio Bravo
12 years ago

“You seems to follow GWT closely, can you let me know if there are any good GWT widget libraries?” so far we have not needed to use libraries of widgets, we uses Html + CSS layout. I know developers who are using gxt smoothly . The license is very affordableSince 2007 things have changed a lot.”.I see  the amount of code you need to write, to achieve a task, is very less when compared to GWT”, With uibinder and html + css layout, the amount of code required is less. Using proper implementation of the MVP architecture help when the project… Read more »

Adisesha Reddy Gaddam
Adisesha Reddy Gaddam
12 years ago
Reply to  Emilio Bravo


we uses Html + CSS layout’
We generate UI at client side using meta information from server. 

‘Since 2007 things have changed a lot’
I can see that but not enough for us to move to it.

On amount of code, lets agree to disagree :) 

Thanks for info on Dart. 

Dmitry Matyukhin
Dmitry Matyukhin
12 years ago

ExtGWT, GWTExt, SmartGWT to mention just a few

alex craciun
alex craciun
12 years ago

I agree with most of the cons and pros from the article. GWT seems like a good proposition for Java developers, but it becomes soon too complicated for what you really need. Our project STJS (http://st-js.sourceforge.net) takes an approach that tries to benefit from the impressive IDE support for Java (compared to Javascript), while taking advantage from existing Javascript frameworks, like jQuery. Also it’s much easier to learn and master.

Dapeng Liu
12 years ago

UiBinder solves most of the problems with GWT

java codes are exclusively for event handling, logic processing

rest of the work is left to UiBinder, the good old HTML+CSS combo still works 

most of the time my ui.xml is 

  

   …
   …

 

Antonio Petrelli
Antonio Petrelli
12 years ago

About number 8 con, notice that MVP and the Editor framework can significantly remove much of logic code from the presentation layer.

Michał Golichowski
12 years ago

Agree with most, if not all of your pros and cons regarding GWT. I’ve worked with the technology for about 4 years now and, while initially very excited about it (being a person with more of a Swing background than a JS/HTML background), I am not so sure now. Now, one can use GWT as a supporting technology to add additional rich functionality to their existing web page (and it is a perfectly fine solution), but the main use is a more or less pure GWT app. And in this regard, I have doubts now about how friendly this technology… Read more »

nick vajberg
12 years ago


The Java to JavaScript compilation is fairly slow”

That’s my ONLY gripe with GWT. It’s not fairly slow. It’s horrendously slow, and they’ve said it’s unlikely to change because of the way the optimizer work.

And devmode is too slow for many tasks, so frequent compiles are sometimes required.

Federico Pugnali
Federico Pugnali
12 years ago
Reply to  nick vajberg

devmode is slow if you’re using the plugin in Chrome. Try the plugin in Firefox, is very fast. We use very heavy client code and everything works pretty fast.

spnewmex64
12 years ago

I’d rather have a root canal without anesthetics than write ANYTHING in javascript.

KevinCho
KevinCho
12 years ago

From Day 1, I face palmed on GWT.  If you’re a web developer, you should know at least 3 things HTML/CSS/Javascript I honestly believe GWT was inspired by someone who thinks Java is the solution to ALL problems.  He must said something like “I hate Javascript, let there be Java”.  Anyone who TRULY believes that GWT requires 0 Javascript is a fool.  If there’s a bug, then you’re going to see Javascript *gasp*.  I rather debug my own code than auto generated GWT crap that only Java communist can understand. If you place yourself on Javascript developers, you’ll understand better.… Read more »

Yanbin (Henry) Zheng
12 years ago

We used GWT to build a mid-size web application. It met our requirements except that the the download size is too big. Loading time could be as long as 10 seconds. We have tried many techniques to reduced the size but it didn’t help much. We are going to switch to jquery for our next project.

Nir M
Nir M
12 years ago

You can use code splitting in GWT in order to download parts of your app asynchronously.
If you use the GWTP framework it is very easy to annotate a place in your app to be downloaded separately only when the application needs it.
GWTP is awesome, check it out: http://code.google.com/p/gwt-platform/

Troy Borja
Troy Borja
12 years ago

Our small dev team uses GWT 2.4 (Uibinder, RequestFactories, Activities and Places, Custom Widgets, Code Splitting, GAE or CloudSQL) to build cloud based web and Facebook applications. With very minimal code change we are able to run the same web applications on a local server using MySQL if the original was written in CloudSQL. App runs well on a browser, mobile phone or tablet. We do not use any widget that is not from Google. Currently we are testing the use of the same RequestFactories used on the web for use in Android apps. We are also testing using GWT… Read more »

Isn't Man
11 years ago
Reply to  Troy Borja

This shall convince me I have made a right decision making a cloud application using GWT. to launch it within 8 months ahead. I am quite confidence with GWT and of course, it’s from Google.

porkchop
porkchop
12 years ago

Javascript is FAAAR more suitable to event based coding (I.e. browser apps or scalable server apps). Plus it is truly a much much better language than Java.

Harry Keller
Harry Keller
11 years ago

Having written massive amounts of Java and vast quantities of JavaScript, my view is very simple. Use JavaScript when you must — as in cross-browser UI. Use Java mostly because it’s a true programming language with strong variable typing. I’m just now getting into GWT. My team has just transitioned from an HTML/CSS/JS + Java applets and servlets system to a 100% Java application to avoid browser dependencies. In order to provide mobile solutions (and Chromebook), we are working on changing our system (50,000+ lines of Java) into GWT. This is not something we do lightly. The Java application plus… Read more »

roger
11 years ago
Reply to  Harry Keller

Let us know when you’re done and how it went overall…
also what did you mean by jws here?

Bobby
Bobby
11 years ago

I’ve been a MS developer my whole life – latest silverlight frontend with .net backend. it took about a month worth of work but finally we implemented a smooth process to develop single page GWT apps in Eclipse, using .NET backend/web services developed in visual studio 2010. On the .NET side we receive/transfer all objects in JSON rather than XML. On the GWT side we use overlay types. We wrote an app which generates code (from the .NET app) and automatically writes it to our GWT project – it generates all classes that we need and also writes functions for… Read more »

Erwin
11 years ago

I have some opinions, that I consider, are not concerned in this post. GWT is cool if it’s habitual for you to use the Google PLs or APIs, many of them are pretty nice, but keep in mind that that some functionalities turn free into payment. So, don’t develope projects seeing long term if you are not considering that reality. I know many friends who got dissapointed when the API of Google Traslate turn into payment. Many projects and good biz had to recalculate their existence. Books?, well are not necesary today, and that’s why I recommed beginner programers to… Read more »

Mike
11 years ago

First I would like to thank Ganeshji Marwaha. Excellent article, and the responses are equally helpful. I first started using GWT because I wasn’t a javascript wizard. Later, I became a little more adept at javascript using JQuery, and then angularJS (another framework developed by google). The one thing I like about GWT is that setting up UIs for mutiple devices/cross platforms is quite nice. MGWT written by Daniel Kurka and along with the google team did a wonderful job. However you do feel like you are handing over a little control when you use GWT. If you don’t have… Read more »

DevAnatoli-Kampala
10 years ago

Well, for the last 1 year at the university, i have started developing java enterprise applications seriously. GWT together with SmartGwt seems to be the future. Giving a web application user a desktop feel is what our clients are doing for. Loading pages every tyme annoys, Switching from one page to another is a pain to users. Load Resource once and let the user enjoy their work. Finally GWT alone is not perfect, but if extended with with frame works like smartgwt and sencha gxt, Staff works out pretty well! “For a Java developers, we are System developers not website… Read more »

Back to top button