The Power of Javascript: An Introduction - Meet Javascript
(Page 2 of 4 )
There is a big misunderstanding about the Javascript language. Some of you may think that it's a minimized version of Sun Microsystems's Java programming Language, and others think that it's a very easy to learn programming language that has been designed specifically for use in Web pages and by non-programmers (Web designers). This is very misleading information about Javascript, so let's meet Javascript.
Javascript is a scripting language, which is different from programming languages like Java, C++ or Visual Basic. After you write an application in one of those languages, you use a tool called a compiler to convert the code you have written (for example, the C++ code you have written) into an executable file (.exe file) that contains the binary data. The compiler takes the C++ code (or Java) and converts it into a binary file, which the computer understands. This process is done only one time for the program; then you can load the program into memory and work with it. This is not the case with Javascript; we don't have a Javascript compiler.
As a side note, if you don't know what a binary data file is, let's just say that computers don't understand any of the programming languages we use, like C++ or Visual Basic. Instead, they only understand 0s and 1s, because the computer's memory contains millions of electrical circuits which have two states, 1 or 0, or much more like on or off.
As we said, Javascript is a scripting language, so let's explain what this means. A scripting language doesn't use a compiler in order to execute the program code. Instead it uses a tool called an interpreter. Let's explain what happens when you want to run a Javascript program (actually we call it a script here, not a program).
You have written Javascript code and you need to execute it. You load the code into the interpreter, and it will execute the code for you (you will understand this process more when we look at the Hello World example). This happens each time you want to run the program (the script, I mean). This can be used in a wide range of applications and systems but this is not within the purview of our discussion; in this series we discuss Javascript use in browsers only.
So Java uses a compiler, while Javascript uses an interpreter to execute the code. They are both different languages and have nothing in common except for some syntax similarity. Actually, Netscape used the name Livescript, but it has been changed to Javascript (something to tell the industry that it's as interesting a language as Java, too).
I will not go into the Javascript versions and browser implementation right now (we will get into that when you get more into the Javascript code). In the coming articles we will just focus on the basics of the language and programming.
Next: The Hello World Example >>
More JavaScript Articles
More By Michael Youssef