Thursday, 29 November 2007

.Net, web browsers and Android should be certified Java Kernel platforms

So I saw Why Microsoft Loves Google's Android (via Stefan) and I couldn't help thinking of the complete opposite position.

Imagine something totally different for a second. You're working at a software house making business applications for your users. You want your stuff to run everywhere, so you use Java on the server. Though you need to do some Office hackery, or maybe you wanna do some Windows specific Silverlight stuff or you've bought in to the MS hype about any day now the words really gonna go Rich Client so you better ditch Java and do .Net or else. So the .Net platform gets more tempting as a development platform to get all the MS crack.

So what do you do? Use Java and .Net and hire both .Net guys and Java guys then deal with rewriting code on both languages/platforms and training your folks on both stuff? Or have two different teams? Or just pick one standard language/platform/IDE etc. The temptation might be to go with more and more .Net - maybe even just .Net. And you know what - thats what MS want! To tempt you with all this Office / Windows / Silverlight crack so you stray from your nice open Java platform to be locked into this Windows / Office monopoly. They want you to leave the Java ecosystem and move over to the dark side.

However there's this thing called IKVM which is awesome - it effectively turns .Net into a Java Platform. Yes you read that right. You can take any Java bytecode and turn it into a normal .Net assembly of IL stuff and it runs like any other .Net thing. With .Net glasses on it looks just like .Net. However with your Java glasses on, its still standard Java code and it looks just like a Java platform. What IKVM does is take Java bytecode and translate it into .Net IL. For years its been able to run ActiveMQ (via Christopher Steen back in 2004!), Tomcat and yes, even Eclipse (think of all that native stuff in there for JFace, SWT).

Indeed with a bit of work (and particularly if Harmony and IKVM got together), .Net could actually get certified as a Java platform! Imagine that for a second. One of the main monopolies trying to tempt developers away from Java to lock them in to their proprietary windows/office platform could actually be a certified Java platform!

What would be really cool is if someone started to build open source APIs to abstract all the Windows / Office stuff using interfaces; so you could deploy on native .Net and use the real MS goodies - but folks could implement those APIs using open source or open alternatives like OpenOffice or Google Docs / Sheet or whatnot. i.e. remove the lock-in and reasons for switching to .Net.

I remember having a bit of a heated discussion with Graham Hamilton on this point at the first Sun Dynamic Language conference; his oppinion was that Java should remain 100% pure and be a single certified platform. I certainly see the value in this.

However another perspective to think of is the developer; and extending the Java platform to as many environments as is possible so that developers never have to leave the Java ecosystem even if they wish to develop on some platform which is not 100% pure and certified to run the "entire Java platform" - e.g. say you don't need AWT, Swing, RMI and CORBA. (Though now I work for IONA I now realise - CORBA rocks! :-)

As a developer in the Java platform ecosystem, its awesome to be able to use a Java IDE and tooling (with other languages for the JVM too like Groovy & Ruby etc) then deploy that same Java code on any certified Java platform plus these other huge platforms:-
  • .Net via IKVM which also means inside Office / WCF etc
  • inside any modern web browser without a JVM via JavaScript using GWT
  • as a C library using gcj so folks in unix/c land can use your stuff
  • on a mobile phone via Android on a platform optimised for phones
In each case today, these different platforms are huge and extremely useful. They extend the reach of the Java ecosystem (basically the bytecode) to run all over the place and avoid lock in by folks like MS to their proprietary platforms. They extend the reach of what it means to "write once and run everywhere" to more and more places including .Net, JavaScript browsers, mobile phones and shared libraries for C hackers. In each case, they take Java code written to a subset of the Java Platform and translate the code to run on another platform.

However today none of these are certified Java platforms.

Now lets talk a little bit about the "Java Platform"; its got a ton of stuff in there that noone really cares about any more. e.g. AWT / Swing is of no value to any of these 4 platforms I just mentioned. (I personally see GWT as a long term replacement for AWT / Swing / SWT)

The Java ecosystem is huge and diverse. IMHO core of Java (java.lang and java.util) should be separated out and made easily certifiable - say called the Java Kernel to indicate its the core language / VM only and not stuff on top like AWT/Swing/RMI/CORBA (that few folks care about any more).

Then we could say that any web browser with JavaScript, the .Net platform, C libraries and Android & mobile phones are all certified Java Kernel platforms; so there's not really any fragmentation like Richard thinks - and its a win-win for the Java ecosystem, extending the reach of the ecosystem to more and more places and further reducing the chances of fragmenting the Java ecosystems (since its not really a fork as Richard thinks - its just a smaller subset).

So I'm all for different platforms which might not support all of J2SE - but do support java.lang and java.util and the Java bytecodes - and I fail to see how tempting more and more folks to stick inside the Java ecosystem, whether its JRuby on Rails, Grails, Android, GWT or whatnot - is nothing but a good thing for the Java ecosystem and a very bad thing for the MS lock-in strategy.

While I'm on a long ramble - I thought I'd mention another of my long term irritations with this 100% pure approach. The Java platform (or Java Kernel platform :) should have amazing C integration for those rare cases when you really need it. There's a ton of great stuff available in native libraries only thats a total PITA to work with in the Java ecosystem. Platforms like Python, Ruby and .NET are still leagues ahead of the Java ecosystem at working with native libraries and sometimes you really need to. Of course we try to stick to 100% pure when we can but you know, sometimes the real world jumps in and we need to step outside the 100% pure mantra.

So in summary - I salute IKVM, gcj, GWT and Android - I hope more and more people figure out neat ways of expanding the reach so the same Java bytecode can run in more and more places than we previously thought possible.

6 comments:

coffeedrinker said...

GWT to replace Swing, SWT? How long term are you talking here?

Long enough for all the major web browsers to implement modern UI toolkits inside, rather than be forced to do HTML rendering? That will be a LONG time.

Good or bad, fat clients are going to be around a lot longer than that.

James Strachan said...

So today you can develop a GWT application with very rich widgets that look amazing and reuses the current web browser technologies (cough, CSS, cough) to make kick ass rich user interfaces that make Swing look pretty 90's technology.

Today GWT deploys so that the client side is *just* a standard web browser; which is great.

It would be pretty trivial to embed WebKit / Gecko inside the JVM process to make a Swing like rich application without needing a browser (as thats what GWT kinda does when you run & debug your GWT application in a single JVM process for both the client and the server side).

i.e. why don't we use a single techology and API to build both rich web applications - and rich thick clients - while using the best techologies available under the hood.

e.g. the Java bean development model coupled with CSS and the modern browser's incredible rendering engines (which make it super easy to make great looking rich applications).

Nicholas said...

You start with the premise that .Net is not an open platform. This is not true. .Net is an open platform steered by MS. Java is an older open platform steered by Sun with a wider market. The question is, will the .Net market be just as wide in a decade?

IKVM does sound cool. I hadn't heard about that.

James Strachan said...

Your definition of how open .Net is might depend on how much you trust MS to do the right thing.

Be that as it may - my point wasn't really meant to be about how open .Net is.

I'm really trying to argue how large we could make the Java ecosystem if we split up J2SE and included .Net, Android and web browers as really being a real part of the Java Kernel Platform - which we could certify too to avoid possible embrace and extend strategies.

robilad said...

FWIW, Jeroen explained a while ago on his blog why he does not think that certifying IKVM makes much sense.

hanum said...

Android is awesome mobile, cool. I like it ;)