JavaScript: The Definitive Guide

Previous Chapter 1
Introduction to JavaScript
Next
 

1.2 JavaScript Myths

JavaScript is a new technology that is rapidly changing. It is not yet well understood and is the subject of a fair bit of misinformation and confusion. Before we proceed any further with our exploration of JavaScript, it is important to debunk some common myths about the language.

JavaScript Is Not Java Simplified

One of the most common misconceptions about JavaScript is that it is a "simplified version" of Java, the programming language from Sun Microsystems. Other than an incomplete syntactic resemblance and the fact that both Java and JavaScript can deliver "executable content" over networks, the two languages are entirely unrelated. The similarity of names is purely a marketing ploy (the language was originally called LiveScript, and its name was changed to JavaScript at the last minute).

JavaScript and Java do, however, make a good team. The two languages have disjoint sets of capabilities. JavaScript can control browser behavior and content but cannot draw graphics or perform networking. Java has no control over the browser as a whole, but can do graphics, networking, and multithreading. In Navigator version 3.0, JavaScript can communicate with the Java interpreter built into the browser and can work with and control any Java applets in a web page. This means that in this version of Navigator, JavaScript really can "script" Java. This new feature is called LiveConnect, and it also allows Java code to invoke JavaScript commands. Chapter 19, LiveConnect: JavaScript and Java describes LiveConnect in detail.

JavaScript Is Not Simple

JavaScript is touted as a "scripting language" instead of a "programming language," the implication being that scripting languages are simpler, that they are programming languages for nonprogrammers. Indeed, JavaScript appears at first glance to be a fairly simple language, perhaps of the same complexity as BASIC. Further experience with JavaScript, however, reveals complexities that are not readily apparent. For example, the use of objects as arguments to functions requires a careful understanding of the difference between passing arguments "by value" and passing arguments "by reference." There are also a number of tricky details to understand about converting data values from one type to another in JavaScript. Even the seemingly simple document.write() method that we saw in Example 1.1 has nonintuitive aspects.

This is not to say that JavaScript is beyond the reach of nonprogrammers. It will be useful to nonprogrammers, but only for limited, cookbook-style tasks. For better or worse, complete mastery of JavaScript requires sophisticated programming skills.[3]

[3] And a good programmer's guide and reference, like the one you are reading!


Previous Home Next
Executable Content: JavaScript in a Web Page Book Index What JavaScript Can Do

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
Hosted by uCoz