JavaScript is a language that has some similarities, but many critical differences, from Java. One can view Java as an extension of a computer language (C++) and JavaScript as an extension of a text formatter HTML. Both are aimed at ``animating Web pages'' that is a superficial description of an interactive client-side application.
Figure 20 shows the simplest JavaScript ``Hello World!'' application. However, more interesting is the example of Figures 21 and 22, which shows a new HTML tag attribute ONCLICK being used to specify a JavaScript routine compute to process data specified in an HTML Form. We discussed, in Section 3.1, how this can be used to build very responsive client-side applications. Our final example, in Figure 23 shows how JavaScript can be used to generate parameterized HTML where JavaScript variables--possibly input in forms--are used to specify dynamic pieces of HTML pages. JavaScript is particularly useful in windows built from multiple frames as it allows actions in one frame to control the URL location and other properties of another frame.
Java was developed by Sun and is an industry standard. JavaScript was developed by Netscape and partially supported by other browser vendors including Microsoft. We believe that although it is no such a well established standard. JavaScript fulfills a clear role, and one can expect one or more technologies like this to be part of the Web ``bag of tricks.'' In Section 3.2, we mentioned the AWT as the basic Java windowing toolkit. One can view JavaScript as the equivalent programmable AWT, but with the (Netscape) browser as the runtime. One can use the Java AWT to mimic JavaScript and have the advantage of a much more powerful and better defined language. However, JavaScript has a major advantage in that the current browsers essentially define a far more powerful runtime than that currently available to the Java AWT. In particular, the Hot Java browser, written entirely in Java, is currently not competitive with the standard non-Java browsers. JavaScript has a built-in advantage (independent of browser capabilities) that is fully interpreted, and it is much easier to rapidly prototype and modify new Web capabilities in JavaScript than in Java.
JavaScript is a more limited language than Java; JavaScript has objects, but no inheritance as in Java; Javascript relies implicitly on the undefined (to the user) browser multitasking threads whereas Java offers the user substantial control over the execution environment with well-developed thread support in the language. JavaScript is used for relatively simple client-side document processing; Java can be used much more extensively including applications involving image processing, simulation, and networking on client and server.