A caffeine fix for the Web


BACK at the beginning of the Internet, Unix machines programmed mainly in C dominated.

This meant that applications were (usually!) portable - they could be run on a wide range of computers without being rewritten for each one.

The programmer's "source code" was compiled, or translated automatically, into the most efficient form for the computer. To run it on another computer the same source code would be recompiled for another machine. Then the PC and the Mac arrived on the scene, and suddenly portability was a big problem. A program which ran on one machine might not run on another.

The arrival of the World Wide Web, and the subsequent surge of interest in the Internet, emphasised this compatibility problem, crystallising the need for portable applications. Just think: a programmer creates a neat Web application which runs on his PC, compiles it, and puts a link to it on a Web page. Only people with PCs can use this link on the Web page, because the program has been compiled for a PC only. So the programmer has to include versions for every platform around.

Back in the early 1990s, a team led by James Gosling at Sun Microsystems realised this problem. In response they developed a new programming language called Java. It is an "object-oriented" language, but more importantly for Internet programmers it is also a portable language.

Its portability stems from its reliance on an interpreter. Every Java program is compiled into a common code, called byte-code, whether the compiler is running on a PC, Mac, or Sun computer. Every machine which wants to run Java programs has to have an interpreter for this code. So as long as your machine has an interpreter, it can run precompiled applications. Portability is no longer a problem!

The power of this portability becomes clear when you use Java in conjunction with a Web interface. Such Java programs are known as applets. An applet is a chunk of Java code that is embedded in a Web page by the introduction of a new HTML tag, . A Java-enabled Web browser (such HotJava or newer versions of Navigator or Explorer), on seeing this applet in the Web document, proceeds to download the byte-code and execute it via the interpreter and display the results in the current Web page.

Using Java and its inbuilt features for dealing with multimedia, Web pages can be constructed that are exciting and interactive. Animation, sound and "intelligence" can all be incorporated in a Web page through Java applets.

Hang on, doesn't this mean I am downloading pre-compiled programs onto my machine and running them? Surely this is a hacker's heaven! Well, security was one of the specific design issues addressed by the Java team. The byte-code interpreter only executes the program after it has been passed by a byte-code verifier a sort of doorman, keeping out the riff-raff of the Java world.

In addition, no applet can read or write to files on your local system, nor can it accidentally (or maliciously) write to protected memory on your system. Admittedly this process isn't foolproof. A clever and persistent hacker might find some loophole; but the Java environment does its best to make this difficult.

What does the future hold for Java? It's hard to say. The current wave of enthusiasm for the language, coupled with a lack of real competitors, bodes well. Sun has formed strategic alliances with major companies such as Adobe, IBM, Lotus, Netscape, and Oracle.

According to Sun, they expect that 95 per cent of Web browsers will have Java interpreters embedded in them by the middle of 1996, thus giving every Web user access to applications written in Java. Making the Sun JDK (Java Developers Kits) freely available to the world was also a good move. Predictions are always hazardous, but I believe Java is here to stay and will play a significant role in the future development of World Wide Web applications.