JavaFX vs GWT

GWT and JavaFX are the only UI development toolkits Java developers need. Old time Java programmers argued about AWT vs Swing and discussed the benefits of Applets, JSF, and regular desktop apps. Now, stick to GWT or JavaFX. There isn’t really any need for the older UI technologies, from a Java programmer’s perspective.

If you’re not clear on differences or benefits of GWT and JavaFX, the two technologies compete, but not directly. GWT and JavaFX are both UI toolkits, but not for the same mediums. It’s like saying ships and trucks are both modes of transportation, but they really don’t compete directly, because one is for water transit and the other is for land transit. The same is true for GWT and JavaFX. They both compete in the UI world, but GWT is for web based apps and JavaFX is for traditional desktop apps that may interface with remote systems.

First, lets step back and look at the world of software. Before the turn of the millennium,  most computers ran their own software. That was the end of the story. Then came web browsers. Web browsers ran on a local computer, but they displayed data stored on the internet or a LAN.

Web browsers have evolved to not only display data from remote servers, but to run programs delivered from remote computers. Often the software that runs inside of web browsers is tightly integrated with remote programs in multi-tier applications that many users share and interact through. The first generation of multi-tier web based applications ran their client UI’s in web browsers only, but now even that has evolved. Modern multi-tier web applications often have front-end clients that are not web browsers. Modern multi-tier clients are often customized for the needs of the application, eliminating traditional web browsers completely. Internet applications often run on custom software that is not a web browser, even when the data and client UI code is written in HTML5, CSS, and JavaScript.

So the question of how do GWT and JavaFX compete is really the question of where do each of the technologies fit in to the new world of multi-tier web applications and clients?

GWT

GWT is Google’s Web Toolkit. If you’ve ever seen any of Goolge’s incredible web based applications, you’ve seen GWT in action. GWT UI’s are written in a subset of Java and then run through an optimizer and complier that compiles them down to JavaScript for use in HTML5 screens. HTML5 allows for regular HTML form and UI elements, and very importantly, for the HTML5’s Canvas object.

What that means is that GWT can be used to create any range of applications that are made for HTML5. This includes regular forms and word processing apps used in typical office situations, and even fully 3D interactive games with nice graphics.

Very importantly, GWT has full integration to communicate with Java servers, and allows for creation of “responsive” sites. Responsive sites are sites that work on desktops, tablets, and cellphones. That is the power of GWT.

JavaFX

JavaFX creates desktop application UIs. JavaFx, unlike Swing or AWT before it, is built with the MVC or MVP design pattern in mind. The UI can be (and probably should always be) created with FXML in a RAD tool called SceneBuilder. The Controller is set up in Java via dependency injection and kept completely separate from the view code. That alone makes it a huge leap ahead of older Java UI technologies.

Another huge advance over Swing and AWT is that JavaFX allows swapping of scenes in and out of the stage with ease. That is the equivalent of allowing Swing to swap panels in and out of Frames or Windows at will. Trying to add and remove Panels from Swing and AWT windows often ended up with undefined results. The view often summarily crashed or just displayed gibberish.

Of course, Java FX handles 2D and 3D graphics nicely. However, the benefit of JavaFX in the modern world is that it displays HTML5 pages nicely. In other words, you can use JavaFX applications as specialized clients in your modern multi-tiered universe of software, completely replacing clunky web browsers.

GWT vs JavaFX

So GWT allows for the creation of beautiful and powerful HTML5 clients for multi-tiered software. JavaFX allows for the creation of customized clients to replace web browsers in multi-tiered software. Because JavaFX renders HTML5 pages very nicely, there is no reason GWT and JavaFX couldn’t be used in the same multi-tiered applications. You could use JavaFX to eliminate the traditional role of the web browser, and use the custom JavaFX application to display GWT pages. All of this of course takes advantage of the immensely popular Java programming language.

GWT and JavaFX are not so much competitors as potential teammates in the creation of the next generation of web and LAN based applications.