Alex headshot

AlBlue’s Blog

Macs, Modularity and More

Too little, too late, too bad

2007, java

So, Sun have announced JavaFX at JavaNetBeansOne this year. Strangely, the name was better with Form Follows Function, or F3 as it was previously known.

I realise that Flash has been kicking Sun’s butt in the web space for some time, and that the announcement of Flex has probably got them worried. And it doesn’t help that Microsoft has timed their Silverlight release admirably. But they’ve gone around it completely the wrong way.

Instead of adding more bloatware to the JVM, what about removing some of it? Or getting a modular VM, like Harmony provides? Instead, we’ve got another random acronym with Java on the front (think: JavaScript, but even less related). And to take the piss, you’ve got to have a full JRE downloaded on the client to even consider running any JavaFX code. So, that’s 15Mb for the JRE, and another 10Mb to get the JavaFX code (well, the last one includes documentation too). Now compare this to the Adobe Flash player, which is a paltry 2Mb. Which would you prefer? And, in addition, wouldn’t you prefer something that didn’t require you to download the entire JRE every time someone creates a bugfix for a library you probably don’t call anyway in the javax.midi package, or force you to restart your computer? (Not to mention the über-annoying update scheduler …)

Now, compare that to the competition:

  • Adobe, who have great track record in the client space, and have recognised the importance of providing versions that run on all operating systems. Result: they own the video and interactive web market.
  • Microsoft, who have enough market clout to force a system on developers, particularly one that uses the same language/tools as their proprietary client/server side
  • Apple/Quicktime, who dominate in the music market and is one of the few reasons why Quicktime is installed anywhere

Let’s face it, Adobe own the web browser for interactive content. Microsoft’s push is to be applauded, though their past credentials and behaviour don’t instil confidence (and ironically, will be the main obstacle to Silverlight’s success). The thing that probably will kill it off is not supporting Linux, in much the same way that Apple’s QuickTime is doomed to failure outside of the Mac/iTunes market. (One benefit of QuickTime is that it will play industry standard MPEG-4/H264, whereas Silverlight comes encumbered with Microsoft’s VC-1 codec that nobody uses.)

But where Microsoft really have Sun by Duke’s short curlies is that they realise it’s about the runtime, not the language. Sun seem to be blinded by JAVA on everything that they do. (Why JavaFX Script? Don’t they realise that that might cause confusion with JavaScript? Cue CVs from clueless recruitment agents who start looking for developers with 10 years JavaFXScript development …)

You only have to read The One True Object that discusses the DLR’s object model, and the fact that instead of auto/un/boxing/wrapping each object across a language boundary, the property of an object is consulted cross-boundary instead. That means you can have a C# GUI which takes (and displays) the results from an IronPython class. That’s really powerful. Apple has used this to great effect with their Objective-C applications and AppleScript; all AppleScript does is query the objects by property, and so can hook directly into the runtime. Imagine what Java would be like if we had that; you’d be able to install plugins written in Python into your favourite Java-based IDE. Or JRuby. Or Scala. (Oh hang on, someone’s already done that.)

Not only that, but the DLR allows you to annotate methods on an existing class. So, if you have (say) a String class, and you expect it to have a substring method (but instead, it has a SubString one) you can actually add the substring method yourself to the existing String class. In fact, this is what happens when treating Strings in IronPython; the String is decorated with the existing Python-esque properties and methods so that any python classes will see it as a String, even though it’s the standard CLR String class. This is amazingly powerful (and it’s been in Objective-C in the form of categories for ages, as well as other languages). If Sun were serious about the life of the JVM, this would be something worth paying attention to.

Instead of making the JVM first class, Sun are going down the same road that they’ve always done. Bloat is piled upon bloat, and from simple beginnings (Java 1.1 was 2.5Mb, pretty much the same size as the flash player is now) has grown massively (the classes.jar alone is over 10Mb on my 1.4 install). What we need is smaller systems, not larger ones. And let’s face it, not only has OSGi already achieved this, Sun has too in the form of the Java ME. What’s really needed is a dynamic system that can just download the parts of the VM+library combination that you really need. Want to program in JPython? You should only need to download the VM+JPython libraries. Have a (shudder) JavaFX applet? Just the VM+JavaFX code. And it should be plug-and-play; when you install new features, they should be available to others, but not mandate them.

Mind you, this is only going to happen if Java adopts a decent module system (as opposed to writing their own). Somehow, I can’t see that happening. Oh well, I’m off to play around in Silverlight.