In this inaugural issue of JavaWorld, we will introduce JavaScript to interested novices with a short series of articles covering technical aspects of JavaScript and its functionality. Since I would rather we not try to fly before we can walk, I will first go over the very basics of the language and its structure. We will do very simple examples that you can add to your page and then try some more interesting projects in future articles.
Contrary to some beliefs, JavaScript is not merely a decaffeinated version of Java for beginners and novices. The LiveScript/JavaScript animal is quite separate from direct Java applets and applications since it provides the functionality for a different niche in the market. It is, primarily, a solution for Client-side APIs in Netscape Navigator 2.0. The discussion of the use of Client-side Application Programming Interfaces (APIs) in the world of the Web, once Server-side APIs had caught a hold, is still ongoing. The push toward moving the application processing from an already weighted server to the local user's interface came with the improvements in end-user desktop technology, both in hardware and software. With the increase from 486-based to Pentium-based and 68000-based to PowerPC-based PCs, the ever dropping price of secondary storage and memory, the technical demands of the average user are also increasing.
JavaScript provides this client-side API to take care of the nuisances of static Web text. Netscape is also working on creating a server-side system with JavaScript, possibly with a link to the Common Gateway Interface (CGI) for backward compatibility. It is currently available on all the Netscape 2.0 beta version browsers and runs on all the different platforms. Note to Mac users: the fact that JavaScript is available in the Mac browser doesn't mean that your Mac Netscape 2.0 browser can do Java applets. The Macintosh and Windows 3.1 versions of the Netscape 2.0 still do not support Java.
Formerly known as Java-lite or Mocha internally, JavaScript takes away some of the tedium involved in writing heavy-duty Java applets to do simple calculations or browser control functions. The most obvious difference between the two is that JavaScripts are immediately interpreted by the browser from the source code, whereas Java applets need to be precompiled into a class before actual use. For the lay person this means that the scripts may run slower; each line is interpreted separately, usually one keyword and parameter combination at a time, rather than having faster compiled and code that can be immediately executed by the Java runtime environment within the browser.