For a guy like me, Java is cool. It's a relatively easy programming language to learn, it makes programming quick and fun, and it's forgiving of hasty code-writers like myself. But what's cool to me is not necessarily cool to everybody, especially users of computer programs. Java programs are slow, making them unfit for most high-end uses. In its current incarnation, Java falls short of the huge expectations it has raised.
Before I continue, this disclaimer: I work for Microsoft, the great Satan. Microsoft and Sun Microsystems, the originator of Java, have nothing nice to say about each other. Microsoft believes in Java solely as a language, while Sun believes Java will destroy Microsoft's large, successful computer empire by making Windows obsolete. Consider yourself warned.
What exactly is Java? It's a computer language, like BASIC, COBOL, C, or C++, of which you might have heard. Languages are different from operating systems. Operating systems, such as Windows, Mac OS, and UNIX, control all the basic operations of the computer, deciding which programs get run when. They also coordinate the interaction between the computer and its peripherals, like the screen, the printer, memory, and disk drives. Computer languages, on the other hand, define a set of computer commands. For example, if I want the computer to print some text on the screen, I must describe the steps in a computer language. (There is a bit of a chicken-and-egg relationship here. Operating systems, like other programs, are written in computer languages. For instance, Windows was written in C.)
Java was originally developed by Sun for use on small devices, such as portable game machines and cable TV set-top boxes. But today's Java is a changed beast. Sun has tied its fate to the World Wide Web, recruiting thousands of programmers to write applications for Web pages and network computers. Java works well in a Web environment, unlike COBOL, C, and all the rest. Java makes Web sites more active: You can build games and animations and programs that sort data and display stock tickers. These same types of programs can be written in ActiveX, Microsoft's competing technology (which currently runs only on Windows machines), or in dynamic HTML, another Microsoft technology. (If you must know what dynamic HTML is, click.)
So what's the big deal about Java? People are excited about it because programs written in it are "portable." What that means is that Java programs can easily run on different microprocessors--like the Pentium chip, the Mac's Power PC, or Sun's SPARC, for instance--running different operating systems--like Windows 95, Windows NT, Mac OS, and the various flavors of UNIX, such as Sun's Solaris. Hence Java's catchy slogan, "Write once, run everywhere."
Write-once-run-everywhere portability thrills software developers because writing for more than one operating system at a time is difficult, time consuming, and expensive. Something as simple as telling a program how to write a line on a Macintosh screen is very different from telling it to do the same on a Windows machine. Only a few developers have the resources and patience to write the same program for different operating systems (Quark, Netscape, Adobe, and Microsoft come to mind).
Java can pull off its portability trick because it's an "interpreted language." This means that another layer of programming--a "virtual machine"--exists between the Java program and the computer it's running on. The Java virtual machine understands the gory details of the native computer, such as how to draw a line in Windows vs. how to draw a line on the Macintosh, and frees the programmers from having to think about the idiosyncrasies of various operating systems. Consider this analogy: You're outside a courtyard and want in. You can use a key to open the door, or you can use a ladder to scale the wall. Using a key is fine, but you'll need a new key for every courtyard. The advantage of using a ladder is that it is universal. However, it's a lot slower and more trouble than using a key. Think of the key as the conventional software approach and the ladder as the Java solution.
Another Java advantage, noted in a previous Webhead column, is that it is more immune to computer viruses than ActiveX. Java programs are restricted from mucking about where they shouldn't. So, I could write an ActiveX program that when clicked, would erase the contents of your hard drive. I'm brilliant, but I couldn't do that in Java.
So what's the downside? Java programs execute much more s-l-o-w-l-y than programs optimized for a particular operating system. According to the book Java in a Nutshell, "Java is on average about 20 times slower than C." It doesn't exactly behoove a developer to save time writing applications in Java if they end up running more slowly on the customer's machines. The Corel Corp. learned this lesson this year, when it abandoned plans to create a Java version of its application suite. The Java versions of its word processing and spreadsheet programs simply did not run fast enough in the interpreted environment.
Java also appeals to developers because it's "object oriented." Traditional software is built explicitly for the task at hand. For instance, the spell checker in Microsoft Word is tailored specifically for Microsoft Word's idiosyncrasies. Object-oriented programs are more generic. In the case of spell checking, a programmer could write one object-oriented routine that could be used on a variety of programs--word processors, desktop publishers, spreadsheets, databases, and the like. The wonderful thing about object-oriented programming is that it liberates programmers from having to reinvent the wheel (how many spell checkers does the world need?) and frees them up for more ambitious tasks. Programmers can now buy Java objects (or "applets") for building charts or sorting data, and integrate them into their programs. So what's the downside of object-oriented programming? Once again, it's performance. To work with any program, an "object" (written in any language) must be larger and more powerful than its custom-built equivalents. That makes it s-l-o-w-e-r.
Java boosters boast that their language is easy to learn. But what's the downside of that? (No, the answer isn't s-l-o-w.) Actually, there is no downside. But the reason Java is so easy to learn is that it follows the popular coding conventions of C, one of the most widely used programming languages. The most popular programming language in the world is probably COBOL, still No. 1 at Fortune 500 companies. For an experienced COBOL programmer, learning to use Java is about as difficult as learning to use C. For the novice, Java is a little easier to learn than C, so let's be magnanimous and give Sun that point.
Sun says it plans to solve the speed problem by cutting out the middleman and turning Java into an operating system that talks directly to the computer's hardware, as do Windows 95, UNIX, MS-DOS, and other operating systems. But what's the sense in turning Java into an operating system? The original justification for Java was that it was a multiplatform solution. If you want, you can already choose among Windows, Mac, and UNIX software. Building a Java operating system returns us to square one. Yes, Java programs will run on all computers, but they'll run so slowly on anything but a machine running the Java operating system that nobody will bother to use them.
Java's biggest problem is that it appeals to the wrong people. It makes it even easier for developers to write big, slow programs when they should be completely focused on the end user. Writing in Java is cool to me, but when I'm sipping cocktails on a beach in Tahiti while you are waiting for your Java word processor to start, I think you'll understand the trouble with letting me be so lazy.