Has the JVM design been holding back Java?
Thursday, 18 September 2008
[Note: I've reposted this (with minor edits) as my original post got accidentally deleted. Thanks to Google cache]
Why is it? Why is it that Java applets -despite having the first mover advantage - achieved little traction. While Flash - a tool which targets graphic designers originally - continue to gain mindshare, and is now a serious player in the application space with Flex?
Perhaps it is because applets suffer from slow start up times. Maybe it is because applets crashes browsers when they become non-responsive. Perhaps it is due to heavy resource usage.
None of these are Java’s fault.
The latest client-side offering from Sun - JavaFX - improves the language, but does nothing about the underlying JVM itself (more about JRE 1.6u10 later). JavaFX is a fine language, once you get past the YAML syntax. Unfortunately, the JVM itself is the issue. JavaFX or not, Sun will not see JavaFX overtake Flash on most web pages.
When Flash 1.0 came out, it supported streaming bytecodes, and movies played immediately. JVM’s design requires all libraries to be downloaded, and then verified before playing in the sandbox. [Edit 18-Sep-2008: lispnik pointed out that this has been addressed in Java 6 Update 10]
The JVM implements share-nothing class libraries1, every new JVM process requires run-time libraries to be loaded up separately. This adds another block of run-up time before any screen is visible.
This makes me wonder if the JVM has a fundamentally flawed approach when the use-case is to run in a browsed environment, i.e. where people are moving from web page to web page quickly, and only having a taste of your application, and sometimes, involuntarily, as in the case of a banner ad1.
For browsing environments, I contend that Sun should have bundled some sort of interpreter in the VM, that can process a streamable language, in the manner of Flash. Sure, it is not Java, but it would have guided the evolution of the JVM.
Looking after little details matter. If Sun had cared about applets, and tuned it for lower resource usage, we would have arrived at MultiVMs and OSGI years ago.
The Java camp has a reputation for dogma, e.g. rejecting delegates in favour of anonymous inner classes, static methods instead of standalone functions. There are promising signs of change. Invokedynamic is nearly here - thanks to realization that the JVM needs to support dynamic languages.
Java 6 Update 10 saw a flurry of updates to the JVM precisely to support JavaFX better. This goes to show how little work has been put in to over the past ten years. It is not until Sun - with back against the wall - and a big competitor eating it’s lunch for breakfast, that Sun finally pays attention.
It is late. But not too late. Sun engineers ought to ask themselves this question. “JVM is everywhere. What is Flash doing right but we aren’t?”
Reposted Comments
:
- No. 2 — September 4th, 2008 at 11:55 pm
- Sun engineers ought to ask themselves this question. “JVM is everywhere. What is Flash doing right but we aren’t?”
- Engineers? Strategists rather.
Matt Grommes writes:
No. 3 — September 5th, 2008 at 12:44 am I believe the newest update of the JVM (included with the JavaFX package) includes a rework where it will only download what that app needs to start up, then it downloads other libraries as needed later. So this at least seems taken care of.
1Update 5 Sept, I was wrong. See this
2Incidentally, addressing this use-case on the server-side could be a boon for Java on shared hosters. I would like to see the JVM be a viable competitor to PHP. See Matthieu Riou.
No. 1 — September 4th, 2008 at 11:11 pm
Not true with Java 1.6.0_10 which significantly changes the way applets and webstart applications start.
No. 2 — September 4th, 2008 at 11:55 pm
Sun engineers ought to ask themselves this question. “JVM is everywhere. What is Flash doing right but we aren’t?”
Engineers? Strategists rather.
No. 3 — September 5th, 2008 at 12:44 am
I believe the newest update of the JVM (included with the JavaFX package) includes a rework where it will only download what that app needs to start up, then it downloads other libraries as needed later. So this at least seems taken care of.
No. 4 — September 5th, 2008 at 7:02 am
Hi Bob, Josef, Matt,
Reading the fine-print on JRE1.6u10, I just don’t think download time is the critical factor. The new JRE will continue to have a high memory footprint, as there is still no concept of DLLs shared between java processes.
A basic JavaFX applet will chew up 38Mb. How many web pages do you have on your tabs at the moment? Would you be able to do this if half the pages had JavaFX applets instead of Flash? That, my friends, is the problem.
Faster start up time is a hack. This is called super preloading in OpenOffice. I’m not the only one who thinks this is a bad idea. Steven Bone had written about this back in 2005. Keeping JRE in the warm disk cache messes around with the OS’s pagefile, and causes other applications to be slower when swapping to and from disk.
Unless Java applets gain significant traction, expect most users to go to the forums asking, “I’ve installed the latest Java and my system has become slower. There isn’t even any java applets running.”. This feature will be turned off very quickly unless suddenly applets come into fashion. Unfortunately, applets aren’t coming into fashion because it takes so much memory. What a mess.