10 January 2017

Difference between JAVA and Javascript

What is JAVA?

Java was first released in 1995 by Sun Microsystems. It is a class-based and object-oriented server-side programming language that is used for a myriad of technical purposes. It runs in a virtual machine and was designed to follow the “write once, run anywhere” methodology, therefore allowing the Java code to run on any platform that supported it without having to recompile.

What is JavaScript?

The JavaScript is a Object Oriented Scripting language, developed by Netscape, Inc., is not part of the Java platform. 

JavaScript does not create applets or stand-alone applications. In its most common form, JavaScript resides inside HTML documents, and can provide levels of interactivity to web pages that are not achievable with simple HTML. 


Key differences between Java and JavaScript:


JAVA Javascript
1 Java is Object Oriented Programming language. Javascript is Object Oriented Scripting language.
2 It creates applications that run in a virtual machine or browser. It runs inside browser only.
3 It is compiled. It is interpreted.
4 Java is high-level, static,compiled and strongly type language. JavaScript is text based , dynamic and weakly typed language.
4 It has block based scope. It has Function based scope
and object based context.
5 It has an implicit this scope for non-static methods, and implicit class scope. It has implicit global scope.
6 It has constructors. It has standard functions.
7 I t is class-based. It is prototype-based.
8 functions are only variadic if explicitly marked. functions are variadic.
9 It allows methods in an object to be redefined independently. object are tied to its class, and cannot be redefined at runtime.
10 Java program has file extension “.Java” and after compilation it becomes “.class” file that contains bytecodes which is executed by JVM : Java Virtual Machine. JavaScript file has file extension “.js”
11  In Java there is different datatypes like int, float, string, etc
There is var keyword is used to define variable
12 Example:
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
Example:
<html>
<body>
    <p>Beginning text</p>
    <script>
        alert('Hello, World!')
    </script>
    <p>End text</p>
</body>
</html>