It really irks me when people flaunt their ignorance by referring to JavaScript as Java! JavaScript and Java are two totally different things and are essentially unrelated to each other.

JavaScript is an un-compiled scripting language used primarily in web browsers. JavaScript was originally designed to look like Java and many standard JavaScript libraries follow the naming conventions of Java. Both languages have a syntax similar to C, but that’s more-or-less where the similarities between the two ends.

JavaScript is executed by an underlying scripting engine, which, basically speaking, interprets the un-compiled script into something the CPU can understand. In many cases different scripting engines are used by different web browsers. I guess there is some parallel between a JavaScript scripting engine and a Java virtual machine.

Java is a pseudo-compiled object orientated language which can be used to produce stand-alone applications. Java can also be used (Amongst many other things) to produce applets (I guess this is where much of the Java/JavaScript confusion has its roots) which can be embedded in a page displayed by a web browser. Pseudo-compiled means that Java isn’t compiled to assembly language (The native language understood by the CPU), but rather it is compiled to bytecode which executes within a virtual machine. The virtual machine is the “glue” between the bytecode and the CPU. I have heard that assembler compilers are also available for Java, but why anyone would want to compile their Java code to assembler (Apart from a need for speed) is beyond me, because doing so means that their application loses its cross platform portability.

I’m sure that someone will get on my case because I didn’t refer to JavaScript as being object orientated. Well there seems to be some debate about this. Purists like to refer to JavaScript as being object based rather than being truly object orientated. As far as I’m concerned, JavaScript is object orientated :)

Something that irks me almost as much as those who confuse Java and JavaScript, is JavaScript’s weak typing! Everything is a friggin’ var! Maybe sometime in the future JavaScript will implement strong typing and will mature into a real language (Hehe… I just know I’m gonna get flak for that)!

One Comment

  1. Charl van Niekerk says:

    Thanks very much for writing this; as a person that is both skilled in Java and JavaScript, I have to agree that it rather frustrates me as well.

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word