No I'm not about to troll Kuro5hin but the point stands that as of today I see Java as a hyped, yet very endangered technology. Alas there is a solution at hand. I think that java's only chance for long time success is, wait for it... domination on the desktop!
Yes, I know how perverse the above statement sounds. Remember though, server side Java is under a direct threat from Microsoft and its .NET initiative. .NET is targeted at competing head to head with J2EE and given the enormous mindshare of MS developers and the proportionally miniscule Java mindshare it's safe to say that the threat of .NET is quite real. Not to mention that the ability to leverage Windows functionality in enterprise application development will be quite appealing to server side developers.
I realise that Java with its current VM technology is a no hoper on the desktop and Swing performance is subpar to native widgets. What's the solution? Make Java widgets native. No, I don't mean turning Swing widgets into wrapper classes akin to AWT. Swing widgets have to be native. Yes, my friends I'm talking about a Java based operating system here!
Sun made an attempt at creating a Java based OS called, you guessed it, JavaOS. JavaOS got canned in 1999 for reasons that are still unclear to me but were mostly to do with JavaOS miniscule market penetration. While this was true (I never did come across a single JavaOS based device) there is one advantage that JavaOS had over other up and coming OSes.
Well, market penetration aside Java now had a significant developer mindshare. This is probably as important as getting a large consumer base. Both consumers and application developers are required for a successful OS launch. Sun at least has the latter. It would have been a smart move to start promoting JavaOS on Sun hardware to begin with (as a fast and lean J2EE platform) and move on to consumer devices once the OS and Java gain maturity. Instead Sun approached the issue from the wrong end and ultimately failed. A server OS needs to be robust and scalable but in terms of packaging and ease of use you can get away with more than if you target a home user. JavaOS would have had much easier time in the server space.
Now coming back to the topic at hand, here's how a Java based OS could save Java. Java's memory consumption is pretty awful not because Sun developers are terribly lousy but because Java needs to wrap and ofter reimplement functionality that underpins the OS it runs on. A good example of that is the localisation framework. Instead of using platform specific localisation Java reimplements it in its class libraries because it's easier than trying to extrapolate the least common denominator across so many platforms. Same goes for GUI. Swing is big and slow because it needs to do all that a windowing toolkit does using just the simplest drawing primitives. While that is a good idea for keeping things platform agnostic it adds to the bloat. Same thing for graphics, multimedia, networking and other APIs that java bundles in it's jre.jar. They are all reimplementing a fair chunk of the functionality of your OS in the name of platform independence. That's all good but if I want Java and I want it lean I have no option. A native OS would definitely constitute an alternative like that. I refuse to run Java based applications on my desktop because I don't want the additional footprint of over 30MB worth of different Java classes just to run a relatively simple desktop app.
Just to give you an idea of what I'm talking about I'll use an example. I have Visual Studio 6 running on my laptop right now which weighs in at 9.1MB. I also have JBuilder 4 runnig and consuming a whopping 42MB. But wait, it gets worse. If I now fire off a second copy of JBuilder or any other Java app those same big libraries will be loaded second time eating even more memory. We're now talking 84MB to run two reasonably sized desktop apps as opposed to 18MB native. Not good. Visual Studio on the other hand shares many libraries with other native Windows apps (gdi32.dll user32.dll ws2_32.dll etc) giving me a much leaner memory footprint overall. For java to be a viable desktop solution it has to run natively. The current state of things is not acceptable even for high end desktop systems of today.
An OS based on Java would at least in theory, be able to load the JRE once and have all application instances use the same code in the same way that DLL's and DSO's are reused on native operating systems. This is not the only benefit to having an OS tailored to Java. I'm pretty sure that if you used java applications you've experienced long startup times that are unacceptable to an end user who sees native applications launch an order of magnitude faster. The reason for this (besides the enormous size of the JRE which is 70% of a whole OS by itself) is the way that java loads its classes. Java doesn't work with the concept of libraries. Each class in Java is a separate entity that is only loosely grouped in a .jar file which in actuality is just a zip file with a different extension. The mechanics of loading those individual classes is actually quite crude. Java uses its CLASSPATH variable that tells it all the possible locations of java classes and the virtual machine checks each directory in the CLASSPATH to find the class it needs to load. This is done on a per-class basis and is quite expensive as a result. This behaviour could be much improved in a native Java OS by integrating the class lookup with the file system so that CLASSPATH lookups could be cached and even the most frequently used classes could be kept in memory while the OS is up. I'd expect speed and memory consumption to improve dramatically under such OS.
I can't really see how else Sun could resolve the issues inherent to Java's performance. The JVM will always have to be loaded on systems such as Windows. The performance of the windowing toolkit will always be suboptimal and class loading will always be limited by the filesystem of the underpinning OS. Apple have done some work towards integrating Java into MacOS X but it's not enough. It still comes with the enormous JRE which sits beside the core OS functionality. Much functionality is still duplicated and class loading performance doesn't seem any better compared to running the same Java applications on Windows. The most integration work has gone into the UI layer where Java apps actually do look decent, something that cannot be said about Java desktop applications deployed on all other platforms.
So there. .NET and C# are coming and will be integrated into the Windows desktop most likely will leverage the native libraries as much as possible making C# apps lean and mean. Java as it stands has nothing to respond with. If a Java based OS platform doesn't arrive soon Java may indeed face a bleak future.