|DukeScript - Java Everywhere Again?|
|Written by Mike James|
|Monday, 06 October 2014|
DukeScript is a Duke's Choice winner at JavaOne 2014 and it is another take on the Java dream of write once run anywhere. In this case the target is mobile and web apps.
The key idea is that the UI is created using HTML/CSS. In particular you can use libraries like Knockout. The idea is that you create data models in Java that have values that can be automatically bound to HTML elements. This means that your Java code doesn't work directly with the HTML via the DOM. Instead you generate models using annotations and bind them to the HTML by specifying ids for both the HTML elements and the model properties.
This is a very "hands off" approach and means you can mostly ignore the details of how your data is actually manipulated by the UI - it is very much a Model-View approach. It also means that you can change the UI simply by changing the bindings. Models can also, for example, communicate with the sever via REST or WebSockets via bindings.
You can make use of the new technology as an add-in for NetBeans and it presents you with a complete project template ready to go. However, what you are presented with looks complex and the documentation is not good. If you know how DukeScript works then you will find the JavaDocs adequate, but if you are looking for something simple, like how do I get a connection between a text element and a string of data, you have to work quite hard.
As with so many new Java projects, the whole thing fails because there is no easy way into the new technology. The DukeScript website looks nice and it provides you with a 1000ft overview of what you can do, but how to do it is not so easy to see. There is also a video, but it really doesn't help. When will Oracle realise that the Nighthacking video series is seriously damaging its credibility?
Assuming that you manage to see how it all works and have created an app, you can easily deploy it to any of the platforms mentioned earlier. It is interesting to learn how each of these deployments actually works.
If you deploy to Android then the Dalvik VM runs the byte code and the HTML is hosted by the WebView component. Of course, there is a container app that makes this all work. For iOS a similar approach is used, but the VM is RoboVM.
For desktop deployment JavaFX and a real JVM is used.
So do we need DukeScript?
This is the old way of Java - implement the JVM and then run your code.
It might even prove successful if they manage to make it easy to get started.
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
or email your comment to: email@example.com
|Last Updated ( Sunday, 05 October 2014 )|