vrijdag 4 februari 2011

GWT web development

The Google Web Toolkit is an extremely powerful tool for web development. It basically allows you to program a website in java as if you were designing a Swing application, and then compile it to html and javascript and run it in your browser. It comes with all sorts of incredible tools and features, such as:
  • Support for real-time debugging in your browser. No need to compile to javascript first: with a simple plugin, you can debug your java app directly in your browser as if it's a site. When using Chrome, it also provides very detailed performance and profiling information.
  • Built-in webserver so you can test everything locally (use Wampserver to run a local MySQL database on Windows, by the way, it's the best).
  • Java interfaces for lots of popular API's such as HTML5 Canvas, Youtube, Facebook, etc.
Basically, you write a java app that is translated to a static html/javascript website, which then communicates with a backend server. This backend can be a java (servlet/tomcat) server, or a simple php script that is called through ajax. The default option is the java servlet approach, which is neatly integrated with the client in a java interface. You can pass objects between the client and the server transparently, and they are serialized and deserialized without you realizing it. The disadvantage of this approach is that tomcat servers are hard to come by, hard to set up and hard to maintain.
Setting up a PHP backend is trivial, but interfacing with it is a little bit more of a challenge, as you have to handle the serialization of data yourself. This means a lot of tedious json/xml parsing and object creation. Either way, the choice is up to you, and GWT is fantastic in both scenarios.

The one main advantage of GWT is also its main disadvantage, in my opinion: you are programming in java. Java is a terrible, terrible language for programming games in. In between the total lack of control over your own heap, the lack of multiple inheritance, the lack of stack variables and the impossibility to write readable mathematical code, java is a pain in the ass to program games in. But it's still better than writing directly in javascript and html, so I guess I can live with that problem.

I have been experimenting with several GWT projects in the past month. Line Wars was my first project, and even though it isn't very succesful (nor profitable), it was a good learning school, and it really opened my eyes to the possibilities of GWT development with HTML5 canvas. The canvas context is an incredible versatile and complete drawing environment (much more so than OpenGL or SDL!), and with recent optimizations in javascript, it is no problem anymore to run an entire game in javascript and draw it on canvas. I will write a post mortem on Line Wars in one of the following posts, even though the game is not technically dead yet (I am still working on an AI opponent).

2 opmerkingen:

  1. HI,

    This is really nice post. I like the way you start and then conclude your thoughts
    A good website can be compared to a well-designed retail showroom or outlet that showcases your products and helps you build a brand image among your customers.
    Ecommerce Website Development Company

    BeantwoordenVerwijderen
  2. This is very attention-grabbing, You’re a very skilled blogger. I’ve joined your feed and look forward to in the hunt for more of your magnificent post. Also, I have shared your web site in my social networksrks
    How I can Create YouTube Channel?

    BeantwoordenVerwijderen