Coding By Numbers
Rambling about Java, Swing, JavaFX, Android and iPhone development
Rambling about Java, Swing, JavaFX, Android and iPhone development
Nov 5th
Since I’m effectively relaunching this blog, I thought I would close the loop on JavaFX, which was primarily why I started the blog in the first place. Since the news that Oracle was buying Sun, I’ve not been convinced about the future of JavaFX. In the last couple of months I’ve come to the conclusion that it doesn’t matter what Sun or Oracle does with JavaFX, it’s future as an RIA technology looks pretty bleak anyway. And it’s not alone. Adobe Flash and Microsoft Silverlight are in the path of the same train that is starting to build up a head of steam, namely the combination of HTML 5, CSS 3 and JavaScript. Let’s take a look at the evidence and see why I have jumped to this conclusion!
Two of the biggest proponents of the HTML 5 and associated standards are Google and Apple. Let’s start by looking at their recent behaviour.
About a year ago, Google launched their Chrome browser with the express intent of creating a platform to deliver HTML 5 applications. A few months ago, they announced Chrome OS, a lightweight operating system whose whole user interface appears to be web based. The next release of their Android operating system for mobile devices is also going to feature a HTML 5 browser. Apple have also been making sure that HTML 5 support is in all their products. Version 4 of their desktop Safari browser supports HTML 5 as does Safari on the iPhone. So they are both doing their utmost to ensure that people can use HTML 5.
Google has been re-encoding all the YouTube content in H.264 instead of Flash video. HTML 5 includes a <video> element which will eventually mean that webpages can include video without the need for additional plugins, like Flash Player for example. Apple’s iPhone has special support for YouTube so that the H.264 encoded content can be played, again avoiding the need for a Flash plugin. Apple’s steadfast refusal to allow Flash on to the iPhone is creating a headache for Adobe, as the iPhone becomes ever more popular and web developers are forced to provide Flash free sites (or at least Flash free alternatives) to avoid losing potentially lucrative audience.
The only thing slowing down the adoption of HTML 5 is bickering over the fine details. Everyone agrees that there should be a <video> tag, but no-one can agree which codec(s) should be supported in the standard, meaning that all browsers will have to include them. Most of the arguments are over potential patent claims but the three lead contenders are H.264 (an ITU-T standard), Flash Video (proprietary) and Theora (open source). As well as re-encoding YouTube content, Google has also been trying to buy On2, the company that owns the Flash Video codec (also used as the cross platform codec in JavaFX). Sounds to me like they are hedging their bets!
So two of the most successful technology companies of this millennium would appear to be set on a course to rid the web of Adobe Flash and replace it with standards based HTML 5. If they are making headway against Adobe Flash then the relative minnows of JavaFX and Silverlight stand no chance. Fortunately Sun/Oracle and Microsoft don’t have as much to lose as Adobe, who generate a significant income from Flash related authoring tools. In my humble opinion, they already ought to be thinking about how to leverage their well known and respected tool chain to produce HTML 5 based solutions. I figure that’s their best bet to keep their existing customer base if Flash use starts to decline.
Sadly the same cannot be said for Sun and JavaFX. If it isn’t going to be used for RIAs, what else can it be used for? There’s set top boxes of course, but many of them already use HTML under the hood and HTML 5 will probably do most of what they want. BluRay is another possibility, but you’ve got to figure that the days of physical media are numbered. I think the best bet for JavaFX is as a replacement for the Java language itself. It’s a modern language with some really nice features and would be a worthy competitor to the likes of Scala as the “new” Java. Here’s hoping!
Nov 4th
Originally posted on my personal blog.
Since the start of last week I have been using the beta release of IntelliJ IDEA Community Edition and I have to admit I’m really rather impressed. It hasn’t been completely plain sailing but I’m prepared to give it the benefit of the doubt given that it is still in beta and it’s only fair to expect a few hiccups along the way.
One of the things I like most about IDEA is it’s keyboard centric and code centric approach. To call it a glorified text editor is doing it a disservice, but the feeling I get when I’m using it takes me back to my first job using vi on HP-UX terminals to write software for telephony switches. I don’t mean that it’s primitive, far from it, just that it gets back to basics and puts the emphasis back on writing code.
And yet it provides a tremendous amount of support. The code insight and refactorings are excellent. The inspections help keep you on the straight and narrow as far as good coding practice goes. It’s Maven and version control support is top notch too. The biggest problem is remembering all the keyboard shortcuts in the mammoth keymap.
The distraction free, code and keyboard centric approach means that it also works very well on my 13″ MacBook screen, and for the first time I can remember, I’m actually enjoying coding with it’s limited screen real estate!
In fact the only thing I’m missing from NetBeans is auto closing a line when you enter a semicolon!
Will it sell more copies? I don’t know. As I said in my last post, there’s usually the best option and there’s the option that’s good enough. I think IntelliJ is probably the Apple of the Java IDE world, in that the attention to detail in IDEA is much better than Eclipse and NetBeans. But both those IDEs are good enough for the purposes of most developers. If IntelliJ ever make IDEA Ultimate Edition available for free then the others might be in serious trouble though.
If I were writing web apps every day, then I would definitely trial the Ultimate Edition and if the extra plugins are as good as the Community Edition, I would pay for it out of my own pocket, which is about as big an endorsement as I can give it! I’m also going to continue using it as my preferred Java IDE.
Having said all that I still doubt that this move will significantly increase it’s market. I hope I’m wrong, but in the current economic climate especially, people are going to be prepared to compromise!
Jun 3rd
OK, I admit, I was wrong! Oracle are going to put their weight behind JavaFX and take the fight to Adobe and I’m glad they are because I think it is a superior technology.
I’m also really pleased with what they have included in V1.2, primarily:
This is what the 1.0 release should have included but better late than never.
Apr 24th
One of the main reasons Oracle is buying Sun is to get it’s hands on Java. Much of it’s middleware stack is Java based and having control of Java the language and the default implementation makes sense for them. I don’t really fear for Java or the JVM. If anything I think it will do better under Oracle’s stewardship than Sun’s, just because Oracle get things done. However, that also means that they will be prepared to do what Sun was not, kill off non-profitable areas of the business.
Java targets three markets: enterprise, desktop, and mobile/embedded. Two of those markets have historically received a lot of attention from Sun and have flourished, namely enterprise and mobile/embedded, whilst until recently the desktop market has been left languishing. Obviously Oracle’s main interest is in enterprise Java, that’s the bread and butter of it’s current business. I think Java’s ubiquity on mobile phones and the associated licensing revenue means that Oracle will see a viable business unit there and keep it running.
Unfortunately I don’t see how they are going to make money out of desktop Java. They can’t sell or license the technology, most of the best development tools are free and open source, and most enterprise UIs are heading more and more towards being browser based.
Sun’s decision to take on Adobe Flash with JavaFX has been driving improvements in whole desktop Java ecosystem. Whilst JavaFX has a lot more to offer than Flash because it runs on the JVM, the user experience is still has a long way to go before it even rivals Flash and Flash already plays very nicely with Java back end systems. meaning it can be used to provide compelling front end UI for Java enterprise systems already. I would be surprised if Oracle chose to continue fighting a battle that many people think was won by Adobe a long time ago.
The only saving grace for JavaFX might be as part of the mobile phone strategy (although that already has some excellent UI options such as LWUIT) or on the new battlefield that is emerging, televisions and set top boxes. I believe the next release of JavaFX will add the television profile, and at NAB this week, Adobe demoed “Flash for Digital Home”. Here JavaFX might have a small head start, since every BluRay player already has a JVM capable of running JavaFX, a lot of set top boxes already run Java (I believe), and a lot of the TV manufacturers involved already have a relationship with Sun because they also manufacture mobile phone handsets (Sony, LG, Samsung etc.). Even if this saves JavaFX, it doesn’t mean they will keep it as a desktop technology.
The alternative is that they toss it out to the open source community, and whilst there is a lot of interest and enthusiasm, it’s never going to get gain traction without a major corporation behind it. I hope I’m wrong. I hope that Oracle keeps JavaFX and pushes it on the desktop as well as on TVs and phones. I wouldn’t go betting my mortgage on it though!
Dec 24th
Here are the top three things that I instantly like about JavaFX Script:
The Timeline class is just genius for anyone interested in creating GUI special effects. It makes simple animations a cinch and complex ones possible without tying yourself up in knots. The ability to trigger actions at key frames within the timeline does away with the need for timers and callbacks and events in many cases. The ability to trigger other Timelines makes the possibilities almost limitless.
I’m sure this one would figure highly on any JavaFX newbie’s list of cool things. Being able to hard wire one value to another, even as a function of another, is amazingly handy and helps to keep code so much cleaner. No more change event listeners!
On first impression I really like the declarative syntax. The ability to declare things anonymously where they are needed keeps things clean and lends itself to structuring the code around the UI. I’ve yet to build anything meaty and I have some concerns it may turn into a love/hate relationship when I do, but for now we’re in the honeymoon period!
Dec 21st
As promised, the source code for the Laser Orbit demo is now available as a NetBeans (ANT) project under the MIT license. I refined the source since I originally wrote the demo, as I’ve learned more about JavaFX writing other demos (coming soon). As a result I’ve cut the code down by a third and I’m left with something that is almost entirely declarative.
def FPS = 24;
def SPRINGNESS = 0.2;
def DECAY = 0.8;
def SPAN_DISTANCE = 100;
var current = Point {}
var mouse = Point {x:225 y:200}
var previous = Point {}
var target = Point {}
var temp = Point{}
var random = new Random();
var scene: Scene;
Stage {
title: "Laser Orbit"
width: 550
height: 400
scene: scene = Scene {
content: [
Rectangle {
x: 0
y: 0
width: bind scene.width
height: bind scene.height
fill: Color.BLACK
onMouseMoved: function(event: MouseEvent) {
mouse.x = event.x;
mouse.y = event.y;
}
}
]
}
}
class Point {
var x = 0.0;
var y = 0.0;
}
Timeline {
keyFrames: [
KeyFrame {
time: 1000ms / FPS
action: function() {
previous.x = current.x;
previous.y = current.y;
target.x = mouse.x + (SPAN_DISTANCE - SPAN_DISTANCE * 2 * random.nextDouble());
target.y = mouse.y + (SPAN_DISTANCE - SPAN_DISTANCE * 2 * random.nextDouble());
temp.x = temp.x * DECAY + (target.x - current.x) * SPRINGNESS;
temp.y = temp.y * DECAY + (target.y - current.y) * SPRINGNESS;
current.x = current.x + temp.x;
current.y = current.y + temp.y;
var line = Line {
startX: previous.x
startY: previous.y
endX: current.x
endY: current.y
strokeWidth: 1.5
stroke: Color.BLUE
}
insert line into scene.content;
Timeline {
keyFrames: [
KeyFrame {
time: 0.0s
values: {line.opacity => 1.0}
},
KeyFrame {
time: 1.0s
values: {line.opacity => 0.0 tween Interpolator.LINEAR}
action: function() {
delete line from scene.content;
}
}
]
}.play();
}
}
]
repeatCount: Timeline.INDEFINITE
}.play();
Download the NetBeans project.
Dec 13th
This is a demo that I ported from www.shinedraw.com as an exercise to learn a bit more about JavaFX. Basically the line should follow and dance around the mouse pointer.
Note: I did have this embedded in the page as an applet but it appears to crash FireFox on Linux (not good) so for now I have changed it to a web start application: Run demo with Java webstart.
I learned quite a lot about JavaFX in the process of porting this little example, and I will publish the source and dissect it in an upcoming post. For now, I’ll just say that there is a lot that I like about JavaFX script, but the platform feels quite incomplete for a 1.0 release. Even for this relatively simple example I had to lean on Java on more than one occasion. Fortunately, calling on it’s big brother for help is pretty seamless, so I don’t think it will hold it back.