Has the JVM design been holding back Java?

[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

:

  1. Sun engineers ought to ask themselves this question. “JVM is everywhere. What is Flash doing right but we aren’t?”
  2. Engineers? Strategists rather.
  3. Matt Grommes writes:
    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.

Leave a Reply

Has the JVM design been holding back Java?

Update:Looks like the post has been linked from DZone. Tell me what you think? What kind of projects would you choose Java applets over Flash or AJAX?


After all these years, Java’s applet has not seen much adoption, while Flash continue to gain mindshare. Applets suffer from slow start up times, crashing browsers, heavy resource usage. The latest ’solution’ from Sun is to keep the java libraries in the disk cache.

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 it 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.

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.

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. For example, we would have arrived at MultiVMs and OSGI much faster.

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 and Annotations are nearly here, thanks to realization that the JVM needs to support dynamic languages, and thanks to competition from the .Net camp.

Sun engineers ought to ask themselves this question. “JVM is everywhere. What is Flash doing right but we aren’t?”

1Update 5 Sept, I was wrong. See this
2Incidentally, addressing this use-case will also address resource usage on shared hosters, making Java a viable competitor to PHP. See Matthieu Riou.

5 Responses to “Has the JVM design been holding back Java?”

  1. Bob writes:

    Not true with Java 1.6.0_10 which significantly changes the way applets and webstart applications start.

  2. Josef Assad writes:

    Sun engineers ought to ask themselves this question. “JVM is everywhere. What is Flash doing right but we aren’t?”

    Engineers? Strategists rather.

  3. Matt Grommes writes:

    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.

  4. Chui writes:

    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.

  5. Thierry writes:

    January 2009.
    Even today with 1.6 update 11, the startup time is still much longer than flash player. This is especially a problem when you program applets (can’t the just change the horrible name…?).
    I think JavaFx and java Web service applets can not be popular among developers with this slow strartup.
    Sun has to continue to put all of its energie with this dramatic issue.
    I mean java 1.6 update 11 with a “releaf update”.
    Now if Sun could give us a “wonderfully-fast-startup-jvm-like-Flash-does”, perhaps the java client side java-Swing and java-javaFx could be successfull. Not before I believe.
    Thierry

Leave a Reply