| By Jim Wright | Article Rating: |
|
| June 1, 1999 12:00 AM EDT | Reads: |
10,110 |
To understand what Java gives us, we must first ask the question: "What are the traditional problems with writing cross-platform code using C or other languages?" I'll divide these issues into a few broad categories. The first and most obvious (at least for people with desktop PC backgrounds) is the user interface. Along with the workspace GUI issues, I'll also lump in other less visible "interfaces," often those between the application and the system that, while not presented directly to the end user, often differ across platforms. Some possible examples of this might be text formats (ASCII versus EBCDIC), permissions models (file or process permissions, etc.) or security models. Sometimes it's difficult to spot the assumptions you've made about all your application's interfaces to the user and the system.
The next problem is the availability of compiler implementations and third-party libraries used to supplement the functionality of the standard libraries, with features like database support and additional ADT implementations.
Finally, there is testing, the bane of multiplatform development. The testing effort for stand alone applications on different operating systems is fairly linear. However, when you add distributed application models, the size of the test matrix grows geometrically, as do the number of possible issues related to interoperability, latency and other factors.
Today: Multiplatform Development in Java vs Other Platforms
So how does Java assist with these obstacles? It certainly helps that the UI offers a uniform event-based GUI model with which we can develop applications having a cross-platform consistency. While there have been some complaints about the performance and/or look and feel of Java apps relative to those with platform-native interfaces, we've begun to see applications using the newest Java UI technology, with outstanding results.
Regarding compiler availability, Java delivers a standard compiler implementation that's available across most common development platforms. Plus, Java has recently introduced access to the source for creating modifications and implementations on new platforms. Differing C++ implementations have haunted developers for years. Even differing implementations on the same platform have caused problems. (Witness the VC++/Borland C++ incompatible implementations that persisted on Windows.) The consistency of Java compilers also helps significantly with the use of third-party libraries, ensuring that the chosen library will at least build successfully on your platform(s).
That's the good news.
What about the areas where Java doesn't help and may even hurt us? The foremost problem with multiplatform application development in Java is testing. It adds another complexity multiplier to the test matrix on virtual machine releases and, worse yet, multiple implementations of each release on some platforms. Further complexity is layered on by browser VMs (especially if parts of the application can run inside the browser and others outside) and browsers with plug-in VMs. With layer upon layer of multiplicative complexity from VM variations, the time required for testing can more than double on Java projects compared to the time using more traditional development tools. Some development efforts have seen testing resources jump from 20 to 50% and higher in the transition to Java. The only real solution is more compatible VM implementations. We can only hope that Sun, IBM and Microsoft hear our pleas: "Make the virtual machines more compatible!" Fortunately, progress is being made on this front, albeit more slowly than we'd like.
Putting aside the testing/VM compatibility issue, one primary obstacle remains: the system interfaces for which Java doesn't directly provide an abstraction layer. While it provides strong assistance with application GUIs via AWT and/or JFC, Java doesn't provide packaged solutions to many system interface problems. More are being tackled every day in new APIs and through Sun's new Java Extensions model, e.g., the Java Communication API for serial communication or the Java Cryptography Extension. This is a slow process, though, and there will always be interfaces that aren't covered. The solution here is simple (and certainly not new), although seldom well executed provide the abstraction layer for all nontrivial interfaces to the system that supports pluggable platform-specific implementations.
Platform Pack Solution
At InstallShield our products have to interface to the system using virtually every platform-specific interface in the spectrum, solving many of the problems that aren't directly addressed by Java. The installer has to support almost everything, because it must be able to set up a wide range of applications, from a simple text editor to an application server. In aggregate, the set of applications using our installer utilizes virtually every platform-specific service system-event logging, security and permissions, the file system and on and on ad infinitum.
Some may ask why we should be using platform-specific implementations rather than simply providing cross-platform Java implementations. First of all, it isn't always possible. For example, the creation of icons in desktop services: though it's often essential for rendering an application usable, Java doesn't directly support it, and there's no cross-platform solution.
Second, the use of native services is usually necessary for applications to interface successfully to the existing IT environment. Many new applications must work alongside existing native code, and to do so they often use the same system services as the older packages. Additionally, it's a great benefit for the system administrator to be able to administer applications using the standard tools for the platform. To accomplish this, the application must interface directly to those native tools. Of course, while it's desirable to leverage platform-specific features where possible, we also need to support platforms for which we haven't created platform-specific code, or for which any particular feature is simply not implemented.
When attempting to solve platform-specific problems, our natural tendency is to simply make it work with the platform we're targeting using JNI (this frequently happens when targeting Windows on the client side). While this handily solves the problem for each platform on a "one-at-a-time" basis, it gives up the "write once, run anywhere" promise of Java.
To fully realize this vision, what's needed is a robust and flexible architecture for implementing a set of platform-specific services in a cross-platform application, while also maintaining gracefully degraded performance on other systems. We call our solution "Platform Packs." For the most part, it follows the same pattern as Java's existing interfaces to platform services the separation of the definition of functionality in cross-platform Java classes from the implementation of that functionality in platform-specific VMs.
The basic idea of the model is the creation and use of a set of named system services for the implementation of platform-specific items. At application startup, a "Service Manager" examines the system properties to determine the current running platform; then it finds an implementer for each service for that platform and performs any necessary startup for the service implementers, usually launching a service-implementer application, either one for each service or one for all of them.
Why a separate application? First, these platform-specific services are usually in a native executable generated with C/C++ or another native development tool and native libraries. Second, even if the service implementer is a set of Java classes, you may want to run the implementer on a separate machine or in a security context separate from that of the Java VM.
What if a service implementer for a given service doesn't exist for the current platform? The solution is to create a platform-neutral implementation for each service. When an unknown platform is encountered or an implementation of any particular service doesn't exist for the current platform, the platform-neutral service implementers are used. For some services, a platform-neutral implementation won't be available or obvious. However, in these cases the developer simply creates a nonfunctional shell service and lets the caller know that the service isn't implemented on any calls.
One example of a service requiring this approach is desktop services creating icons and such. There's no platform-neutral way of doing this (yes, I can hear your screams, CDE fans!), so the platform-neutral desktop service must simply return an E_SERVICE_NOT_IMPL error in any call to the service.
The following is a list, by no means all-inclusive, of other services you'll need to think about in your application: &127;&127;
Conclusion
The core of this strategy is simply to implement as much as possible in Java, including a pure Java implementation of each service area to form a platform-neutral pack. Additional platform-specific functionality can then be implemented in platform-specific native code on a service-by-service basis and activated at application startup by the service manager. Keep in mind that you may not require all services to be implemented for each pack. It's essential that the implementer of the Platform Pack for each environment be able to pick and choose when to use the platform-neutral implementation and when to use native implementation. An example from our product is the registry, which uses the platform-neutral implementation on Solaris and the native implementation on Windows, which maps directly to the Windows registry.
This allows use of the product across virtually all platforms, but with gracefully degraded functionality on those platforms for which no native functionality Platform Pack exists. Additionally, if your service manager allows the detection and creation of the set of available services at runtime, new applications built on the existing framework will be able to request and utilize new services without requiring modification to the service manager or any existing services.
I hope this discussion has provided a useful look at a successful strategy for the implementation of multiplatform applications in Java. Java clearly solves some of the biggest problems with development for heterogeneous systems, assisting us with consistent compilers, class libraries, some system interfaces and UI. While it doesn't solve all of our problems, a little forethought in the design of flexible system interfaces can greatly ease the burden of transitioning applications to new systems.
Published June 1, 1999 Reads 10,110
Copyright © 1999 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Jim Wright
Jim Wright lives in Santa Cruz and serves as the general manager of Java product development and director of developer relations at InstallShield Software Corporation. A consultant before joining InstallShield, Jim has worked in the areas of Windows application development, software installation, networked and widely distributed applications, and encryption systems.
- Patterns for Building High Performance Applications
- It's the Java vs. C++ Shootout Revisited!
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Cross-Platform Mobile Website Development – a Tool Comparison
- Three Buzzwords That Every CIO Hears but One They Should Listen To
- Write Once Run Anywhere or Cross Platform Mobile Development Tools
- Immersing into JavaScript Frameworks
- Workday Reportedly Prepping to Go Public
- Cloud Expo New York: The Java EE 7 Platform - Developing for the Cloud
- Book Review: Sams Teach Yourself Java in 24 Hours
- OpenOffice.com Lives
- Book Excerpt: Introducing HTML5
- Adobe Sends Flex to the Apache Foundation
- Five Years Waiting for JRE 7: Is It Justified? (Part 1)
- Book Excerpt: Java Application Profiling Tips and Tricks
- i-Technology in 2012: Five Industry Predictions
- Patterns for Building High Performance Applications
- It's the Java vs. C++ Shootout Revisited!
- OpenXava 4.3: Rapid Java Web Development
- The Next Web Architecture
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Is Write Once Run Anywhere Ever Going to Be a Reality?
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- JavaServer Faces (JSF) vs Struts
- The i-Technology Right Stuff
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- What's New in Eclipse?
- i-Technology Predictions for 2007: Where's It All Headed?




















