Home > GWT > Why Google Web Toolkit (GWT)?

Why Google Web Toolkit (GWT)?

In this article I’m going to describe my point of view on such great technology as GWT and try to explain when and why you must choose it. Because GWT adding a lot of complexity while developing applications you need to know exactly why you add this complexity to your development process and where you will receive benefits from it. 

Ok, let’s start. I will add a links to other articles on which I based during this research.

First of all, you need to decide what is your application will be and do you really need to develop it as Rich Internet Application (RIA). What is Rich Internet Application? Let’s try to get a definition (based on Wikipedia, but my thoughts added):

Rich internet application – is a Web-application that has a many characteristics of desktop software, from user’s point of view it loads once from Internet and looks like as monolithic application. In ideal way, user won’t know that app interact with some data servers, until he will try to use it without Internet.

Based on this definition, first criteria appear – if your goal is to provide user with some data and you don’t want to provide any tool to work with this data then you definitely don’t need RIA.

Second criteria, are there a lot of interactions between the different pages/parts of your future application? If not – probably AJAX + new HTML5 standarts will be more than enough for you.

Third criteria, based on the “taking behavior of desktop software” – if you will have a some amount of components and different combinations from them will provide your main application logic then you definitely need a RIA. 

I believe that there are some other criteria you can told me, but because every application is specific challenge and there are no silver bullet exist, you should find them by your own. Some more articles about RIA:

Adobe: Benefits of RIA

ReadWriteWeb: RIA: What is it good for?

Let’s assume that you believe that RIA is your choose. Now, you need to choose between main players on this scene: GWT, Flex, Silverlight, JavaFX. Also googling with request like “RIA vs HTML5″ you can find a lot of articles that HTML5 is killer of RIA. My opinion on this: HTML5 is a new, groundbreaking standart of HTML, but html is about how web page look and feel, not about web page interacting between each other or interactivity. You’ll also need a lot of scripts inside this HTMLs to make it look and feel like RIA. So, you can definitely try to build a RIA using html5, but … let’s me say first about one of the main characteristic of all tools counted above – they are all object-oriented and strong typed. (Actually FLEX not strong typed, but you can do this something like this). Where complexity of creating this applications pays you back – when you reuse components (OOP) and when you trying to find why one of your N components failed to display something (Strong typing). Now, you can back to my criteria of RIA and see from where them appear. So, backing to html5. You see that you lose this ability of strong typing creating RIA on HTML5 and if, Wikipedia says truth, increase the cost. But instead of this you receive higher speed of development, easy deploys, avoid problems with indexation in search engines and injecting other widgets/components not belong to your site (which is very important ability, and I think even one article will not be enough to display benefits from this, but for RIA this is just a problem, not impossible). There are a lot of articles where Flex vs GWT vs Silverlight compares (one, two, three, etc). I’m not experienced in other technologies from list except GWT and HTML5, so rest of article will be about GWT benefits. It’s possible that other solutions have some features that I don’t know about and they make them more pretty to your product. My advice here try to find a people that experienced in this or that technology and ask them and then compare and choose what is cool for you.

Let’s see what GWT offers to us:

  1. SDK
  2. Debug tools
  3. Optimization tools
  4. Spring back-end framework integration
  5. Cross-browser support (for mobile devices too)
  6. A lot of cool and powerful libraries (Mvp4gGIN, gwtquery, gwt-dnd, PlayN, etc)
  7. Interactive community (just check groups)
  8. GWT designer 
  9. Possibility to create a strong test-coverage on JUnit

Go to GWT site and check all basic components and documentation – it will say better than I.

Rather than describing basic I’ll better say about some basics that really can help in GWT.

There are a lot of tutorials as well as best practices in GWT. You can check them on GoogleIO sessions and google web toolkit sites. But some of them must see or read and I’ll share them:

  1. GWT App architecture best practices
  2. Large scale applications and MVP
  3. Declarative layout with UIBinder

I will add some comments about this articles. There are my favorite pictures when I’m talking about big application and patterns

This is what will be if you don’t use any architectural pattern and (one more stone in the HTML5 garden) you’ll never find an ending in this if there will be more modules and objects. But this is with using MVP:

Much more easier and easy to find bugs and design a code. You can read a details in article, goal of showing this picture was to show you why you need to read this articles.

According to UIBinder it’s allows to create a declarative layout for your widgets, as well as create a parts of markup on pure HTML + css using HTMLPanel. One of the main benefits of GWT – you can split parts of your markup to different components, and then just gather them together in simple way with UiBinder. It allows you to use tables (why tables? ) for block holders that works much more stable and because they are pretty small not creating any overcomplexity in read and maintain (this before CSS3 grid will be introduced).

Some more about frameworks gwt provide:

  • Mvp4g – a perfect, clear and easy-to-use implementation of mvp.
  • GIN – implementation of google-guice (dependence injection) for gwt
  • gwtquery – clone of jQuery in GWT
  • gwt-dnd – out of the box drag-n-drop library
  • PlayN – framework for creating a bad-ass games that allows you to compile same code in more than 4 platforms.

All of this libraries simplify development a lot. Take a look only at gwtquery – this is an almost full clone of jQuery, so you have all power of jQuery inside of gwt, isn’t it cool?

Ok, what is the main benefit of GWT before Flex and Silverlight – you are stay in browser, so you use all new standarts of HTML5, CSS3, WebSockets and other cool things that html5 is provide us. Your page will have absolutely the same rights and restrictions as any other page in Internet. To conclude, You are in HTML5 world with addition of OOP and Strong typing, unit-tests coverage and out-of-the box RequestMechanisms for server-client interaction. Is there can be anything better than this for really big applications with a lot of logic interactions inside? Also, another advantage, that you don’t need any additional plugins to run GWT – only javascript which is part of any modern browser. So, written once your application will run on all kinds of devices, in any popular browser. And last but not least advantage, once you have an ability to write a native methods, you can use and adopt almost any js library to your application, the only question is maintenance of this is not really comfort.

Of course there are some disadvantages in GWT, let me notice them:

  1. Clone of objects (analog of deepcopy in js) not exist
  2. Size of application is pretty big for mobile devices
  3. Compile process is pretty slow
  4. Big resources are needed for development machine (development mode consumes a lot of resources)

For all this problems and disadvantages there are some workarounds and optimizations, but they are not easy and require resources.

For conclusion I’ll put all pros and cons into one list.

Pros:

  1. Writing on Java1.5 with all benefits of Java, OOP and Strong typing
  2. Ability to write unit-tests and debug application
  3. You’re still in html – you can write native methods and use all html novelties and cool tricks
  4. Ability to use directly js libraries (examples: bitly, google-analytics)
  5. History management for RIA
  6. Cross-browser
  7. Low maintenance cost
  8. Reuse of components
  9. Lot of powerful frameworks
  10. Open-source
  11. Friendly and pretty big community
  12. HTML5 support
  13. Best architectural solutions – out of the box
  14. Profilers included

Cons:

  1. Clone of objects (analog of deepcopy in js) not exist
  2. Size of application is pretty big for mobile devices
  3. Compile process is pretty slow
  4. Big resources are needed for development machine (development mode consumes a lot of resources)
  5. Overcomplexity on start for supporting and maintain this architecture
  6. Most of kick-ass library are closely linked to JAVA back-end
  7. Speed of development (long time for waiting pages to refresh compare to pure js)
  8. No runtime configs available.

This is all. Use gwt and don’t hesitate to ask me any questions, I’ll try to help.

 

Categories: GWT Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.