Pages

Sunday, January 15, 2012

Java vs Javascript: Common Misconception


There is a BIG difference!

 Java and Javascript are two totally different *programming languages. Technically Javascript is a scripting language which is a more specialized language than the object oriented design (OOD or OOP) programming language, Java. First misconception cleared!: Java and Javascript are unrelated. Just like the words, "milk" and "milkweed". Milk is a drink (moooooo), and milkweed is a plant (Monarch butterflies lay there eggs on milkweeds).

 Sun Microsystems did not create Java and Javascript. Sun Microsystems only developed Java; not Javscript. The Javascript scripting language was developed by Netscape with a syntax (format) similar to that of Sun-Microsystems' Java. Now, Java is owned by Oracle.

 Javascript is widely used on the internet to create dynamic, interactive, and stronger content than HTML can support alone. When compared to Java, Javascript has more power and dynamism, but less performance.

An example of Java code declaration of an integer:
int counter = 0;

An example of Javascript code declaration of an integer:
var counter = 0;

  "var" which stands for variable can be used to describe an integer, because Javascript will determine the type of variable for you. In Java you must specify the type of variable with the code "int". In Javascript if I assigned a variable to be an integer (var num = 1;) then I can change the variable to a String.

Javscript Code:
num = "subscribe to W7R if this post helped";


 Now, the variable, num is refering (or is equal to) a String, so it is a String data type. This ability makes Javascript more dynamic than Java because if an integer was to be assigned to be a string in Java your program would crash.

To learn more check out the following links!

No comments:

Post a Comment