What exactly is Java? Is it the same as JavaScript? I know it has something to do with the Internet, but I don't quite understand what it is.

Before I explain what Java is, it would be helpful to give you some preliminary background information.

The reason people buy computers is to run programs. A computer program is nothing more than a set of instructions that gets the computer to do what you want it to do, whether it's to write and print a letter, balance your checkbook, or blast an alien in your favorite game. The most basic form of instruction your computer's brain can understand is called machine code, or native code. Each different computer platform—for example, Windows-based, Apple Macintosh, or Unix-based—requires a different type of machine code, since each has a different type of main brain chip (486, Pentium, PowerPC, etc.)

Computer programs can either be written directly in this low-level machine code, which is very tedious, or in high-level languages which are more like human English than primitive computerese, and which in turn generate the machine code. One line of a high-level programming language such as C++, Basic, or Pascal can generate many lines of machine code, making the task of programming much faster and easier.

There are two basic categories of programming languages: compiled and interpreted. With languages like C++ the source code generated by the language is compiled into machine code that can be directly executed by your computer, usually saved as a program file to be run later. With an interpreted language like Basic, the source code generated by the programming language is interpreted and executed by the computer right on the spot, line by line. This makes a program running under an interpreter generally slower than a compiled program.

Now, to answer the question at hand. Java is a programming language originally developed by Sun Microsystems in 1991 as a language for embedded applications such as those used in TV set-top boxes, hand-held devices, and other consumer-oriented electronics. Sun converted it to the Internet's World Wide Web in 1994, and it has started a revolution. The reason? Well, there are several reasons.

First off, although it is considered an interpreted language, Java has characteristics of both compiled and interpreted languages. Java source code is first compiled into an intermediate form called "byte code," which cannot run by itself, and is not optimized for any specific platform. It is a highly compressed representation of the source code, but it is not machine code, and therefore not tied to any particular hardware. This byte code is converted into machine code at the time you run the program by a platform-specific interpreter, called a Java Virtual Machine, or JVM.

Normally, programs written for one platform—Windows, for example—must be re-written, or ported, to run on another platform such as the Macintosh. But any platform for which a Java Virtual Machine exists can run programs written in Java. Since the Internet is populated with computers of many types, programs written in Java can be distributed over the Internet and run by these varied computers via their JVMs.

This "write once, run anywhere" capability of Java is especially attractive to application developers, and extremely useful for Internet users. Sun's own Web browser, HotJava, was the first to incorporate a built-in Virtual Machine capable of running Java programs, which usually take the form of a little application, or "applet." Netscape Navigator was the next browser to feature Java support, and finally Microsoft joined the club with its Internet Explorer browser. Version 3 or higher of each browser is recommended. On the Web, Java is activated by a special HTML tag on a web page.

Although the most popular use of Java these days is to create simple applets such as scrolling banners and animation on Web pages, it can also be used for building full-blown applications. In fact, Corel Office for Java is the first suite of office productivity applications written entirely in Java and supported by Netscape Navigator 3.01 and higher. It consists of a word processor, spreadsheet, charting program, presentation application, and information manager. The prerelease, or beta, version, which must run within a Java-enabled browser, can be downloaded for free at http://officeforjava.corel.com/.

Given the runaway popularity of Java, a JVM will eventually be built into all mainstream desktop operating systems, allowing Java programs and applets to run outside of a Web browser environment. In fact, the upcoming new version of the Macintosh operating system, Mac OS 8, scheduled to be released sometime in Summer '97, will be the first desktop operating system with built-in Java support. This will allow Java applications to run just as though they were any other desktop applications, including the Corel software suite.

With regard to performance, the fact that Java programs are interpreted at runtime means they aren't exactly speed demons, but some Java VMs include what's called just-in-time compilers (JITs), which significantly increase performance. Java applications can also be compiled into machine language for fastest performance, but they lose their hardware independence as a result.

Java is an inherently secure language. It was designed so that applets cannot alter files on a computer's hard drive unless the client, or user, gives permission. Hackers will find it difficult to use Java applets to spread viruses or cause other damage due to the structure of the Java programming language.

Although all this sounds like fun, Java is a difficult programming language, similar to C++, and is not intended for the casual programmer and certainly not the end user. However, there's another popular language being used to spruce up web pages, called JavaScript, that is somewhat easier to use but not nearly as powerful.

Whereas Java is a product of Sun Microsystems, JavaScript was developed by Netscape, producer of the Navigator Web browser. It evolved from an earlier Netscape language called LiveScript and was renamed when it was made more compatible with Java. This compatibility allows the two languages to be used in conjunction with each other, exchanging messages and data. An example of this would be a JavaScript applet being used to display a data entry form and validating the input, with a more powerful Java program processing the information.

Unlike Java, JavaScript is pretty much a Web-only tool. Current uses include enhanced forms, simple Web database user interfaces, and navigation enhancements. Thus, whereas Java can generate a completely custom interface, JavaScript uses the HTML Web page as its user interface.

As a Netscape product, JavaScript initially was only supported by Navigator. Microsoft now supports it as well, but as a sort of clone known in its Internet Explorer browser as JScript. Since they are not 100% identical, it can be tough to write a JavaScript applet that behaves exactly the same in both browsers.

This inconsistency may soon be over, however, as JavaScript was recently accepted as a standard by the ECMA, a European association for standardizing information and communications systems. This standardization may move Microsoft to officially accept JavaScript and end the war for domination in this arena, since the final standard was worked on by Netscape, Sun, Microsoft, and IBM.

K.O.P.C.Online home > table of contents > Java