JavaScript
Comparison – Javascript Vs Java:
Java is an Object Oriented Programming (OOP) language created by James Gosling of Sun Microsystems. JavaScript is a scripting language that was developed by Brendan Eich and was originally known as LiveScript. JavaScript is a (very) distant cousin of Java in the sense that it is also an OOP language. Many of their programming structures are similar. However, JavaScript contains a much smaller and simpler set of commands than Java does. It is easier for the average beginners to pick up this language to understand.
Java and JavaScript are similar in their syntax. In a way, they’re all children of C. Furthermore, they are both based on OOP (Object-oriented programming). However, the main difference is that Java can stand on its own while JavaScript as an interpreted scripting language must (primarily) be placed inside an HTML document to function i.e. not strong typed. Java is a much larger and more complicated language that creates "standalone" applications. A Java "applet" (so-called because it is a little application) is a fully contained program. JavaScript is text that is fed into a browser that can interpret it and then it is enacted by the browser.
Here are some differences between the two languages:
Java is a statically typed language. A language is statically typed if the type of a variable is known at compile time. This in practice means that you as the programmer must specify what type each Java variable is; JavaScript is dynamic. A language is dynamically typed if the type of a variable is interpreted at runtime. This means that you as a programmer can write a little quicker because you do not have to specify type every time.
Java is class-based. In class-based inheritance, you as a developer write a class, an abstract definition or blueprint from which object instances will be created; JavaScript is prototype-based. In prototype-based programming, the basic idea is that functions can be added to classes dynamically.
Java requires all non-block statements to end with a semicolon; JavaScript inserts semicolons at the ends of certain lines.
Another major difference is how the language is presented to the end user (that's you when you're surfing). Java must be compiled into what is known as a "machine language" before it can be run on the Web. Basically what happens is after the programmer writes the Java program and checks it for errors, he or she hands the text over to another computer program that changes the text code into a smaller language. That smaller language is formatted so that the computer sees it as a set program with definite beginning and ending points. Nothing can be added to it and nothing can be subtracted without destroying the program.
JavaScript on the other hand is a text-based interpreted language and only works well within a browser. You write it to an HTML document and it is run through a browser. You can alter it after it runs and run it again and again. Once the Java is compiled, it is set. Sure, you can go back to the original text and alter it, but then you need to compile again. It's very easy to stop, change and re-run applications written in an interpreted language like JavaScript and that is why they're popular for learning programming. There is no compilation stage needed. Compiling can be a slow process. A large application can take from minutes to hours to compile, depending on how much code has to be rebuilt and the speed of memory, CPU and other system factors.
Java applets run independent of the HTML document that is calling for them (and Java is also what runs many appliances and mobile devices, and does not require a web browser). Sure, they appear on the page, but the HTML document did little more than call for the application and place it. If the programmer allows it, oftentimes parameters can be set by the HTML document. This includes the background colour of the applet of the type of text it