28th August 2002
Question: Is JavaScript the same as Java? If not, what is the difference?
Answer: No, JavaScript and Java are not the same, but they do share a few similarities. Java and JavaScript are both object-oriented tools. The main difference is that in Java you make your own mini-programs, called applets, which the user has to download or install on their machine. This sometimes can slow down the loading of a Web page since the browser has to download these Applets. JavaScript doesn't really have this problem because it is a scripting language that relies on the programmer directing it to perform tasks based on several built-in "tricks" in its library. JavaScript is coded directly into the HTML document, while Java isn't. JavaScript is a little more limited because you are relying on its library, while in Java you create the applet so you control it fully. JavaScript comes in handy to perform tasks when you don't want to create a CGI program, but you want the Web site to do cool things like a sound file playing when the mouse passes over a picture on the Web site. Both tools are excellent for adding a little user interactivity to your Web site. JavaScript is far simpler to use than Java, making it a favorite for intermediate Web designers that want to add that extra flair to their Web site. Also, JavaScript only requires a text editor and a JavaScript-enabled browser, while Java requires the Java compiler and a Java-enabled browser.