Tuesday, August 5, 2008


Java solves the problem of cross-platform application development


Thanks to its portable byte code, the same Java applet will run anywhere the Java Virtual Machine runs. This leads to the logical conclusion that Java is the perfect language for writing applications that need to run across multiple platforms, especially the kind of lightweight enterprise-level applications that IS departments spend much of their time developing.

Java, coupled with a database connectivity package like JDBC, is a good language for things like database front ends and other lightweight applications. It's far more cross-platform than current solutions like PowerBuilder, Delphi or Visual Basic, easier to manage (no installation; just point at a web page) and potentially much higher performance than all but Delphi (which is based on compiled Pascal). But it doesn't solve all the problems of cross-platform development, as a few days reading any of the the Java newsgroups will show. There are three major limitations to Java's ability to do clean cross-platform execution:

Java applets don't inherit the browser properties specified by the user. You can do all you want to make the fonts in an applet match those of the surrounding page. But a viewer on a different kind of system with different defaults will still get a font appearance or size difference between text rendered by the applet and the HTML-specified text that surrounds it. The text of the applet on page two was designed to match the rest of the text on the page. On my browser it does; what about on yours?

Java's window toolkit relies on the native window system to implement all its UI elements: on Unix it uses X/Motif, on the Macintosh it uses the Toolbox, on Windows it uses Windows and so on. Since each window system has its own idea about the size and shape of its components, they are likely to look a little different (a major inconvenience to the documentation people) and to take up different amounts of space.

Which means that the HEIGHT= and WIDTH= specifications in the

-applet- tag need to allow for the largest size required across all platforms, not the size necessary on the development platform. A more serious issue concerns incompatibilities users have found in the behavior on different platforms. Because of the way AWT relies on the underlying window system, programmers have had to make minor code changes (modify the order of API calls; insert an additional call) to make things work on every platform.

For a Java applet to be cross-platform, everything it needs must also be cross-platform. I can write database clients in Java thanks to Sun's JDBC package. But JDBC doesn't do me any good if it hasn't been ported to every platform I need to support. And even if it's available, I need to install it on every system that might need my applet. So my cross-platform environment is really limited by the interfaces accessible to the Java environment in my browser.

This point is discussed elsewhere.
The best cross-platform development and delivery environment I have ever seen was the ParcPlace Smalltalk environment. Every implementation on every supported platform was identical from the programmer's and the program's perspective. Every program behaved identically and looked identical no matter where it ran.

Of course, there was a cost associated with this uniformity: although every Smalltalk program looked like every other Smalltalk program, they didn't look at all like any other application running on the same machine. Smalltalk programs on the Macintosh looked like Smalltalk programs; they didn't look like Macintosh programs.

Until and unless we reach a point where every system looks and behaves like every other (a point Microsoft appears to be praying for with great devotion), it will not be possible to write applications that look and feel like others on our development platform and on every other platform on which they run. Not, at least, without some serious work on the part of the developer.

0 comments: