Difference Between JavaScript and Java

 

      One is a compiled language (the client platform must have an emulator or interpreter), the other is a parsing language (without compiling, the character code in text format is directly sent to the browser for interpretation and execution).

      Although JavaScript and Java are closely related, they are two different products developed by the two companies.
      Java is a new generation of object-oriented programming language launched by SUN company, especially suitable for Internet application development; while JavaScript is a product of Netscape company, its purpose is
to expand the functions of Netscape Navigator, and it can be embedded in Web pages. Object-based and event-driven interpreted language in Java, its predecessor is Live Script; and Java's predecessor is Oak language.
       The following is a comparison of the similarities and differences between the two languages:
  Object-based and object-oriented
  Java is a true object-oriented language, and objects must be designed even to develop simple programs. 
  JavaScript is a scripting language that can be used to make complex software that is network-independent and interacts with users. It is an object-based and event-driven programming language. Therefore, it provides a very rich internal object for designers to use. 
  Interpretation and Compilation
  The two languages ​​perform differently in their browsers. The source code of Java must be compiled before being passed to the client for execution, so the client must have an emulator or interpreter on the corresponding platform, which can compile the code independently of a specific platform through the compiler or interpreter 's bondage.
  JavaScript is an interpretive programming language. Its source code does not need to be compiled before being sent to the client for execution . Instead, the character code in text format is sent to the client for interpretation and execution by the browser. 
  Strong and Weak Variables
  The variables taken by the two languages ​​are different.
  Java uses strongly typed variable checking, that is, all variables must be declared before compilation. Such as: 
  Integer x; 
  String y;
  x=1234;
  x=4321;
  where X=1234 indicates an integer, and Y=4321 indicates a string.
  Variable declaration in JavaScript, using its weak type. That is, the variable does not need to be declared before use, but the interpreter checks its data type at runtime, such as:
  x=1234;
  y="4321";
  the former indicates that x is a numeric variable, while the latter indicates that y is a character type variable.
  The code format is different.
  Java is a format that has nothing to do with HTML. It must be loaded by referencing foreign media like HTML, and its code is stored in a separate document in the form of byte code.
  JavaScript code is a text character format that can be directly embedded in HTML documents and can be loaded dynamically. Writing HTML documents is as convenient as editing text files.
  Embedding is different
  In HTML documents, the two programming languages ​​are marked differently. JavaScript is marked with <Script>...</Script>, while Java is marked with <applet>...</applet>. 
  Static binding and dynamic binding
  Java uses static binding, that is, Java object references must be performed at compile time, so that the compiler can implement strong type checking.
  JavaScript adopts dynamic binding, that is, the object reference of JavaScript is checked at runtime. If it is not compiled, the check of the object reference cannot be realized.

 

      One is a compiled language (the client platform must have an emulator or interpreter), the other is a parsing language (without compiling, the character code in text format is directly sent to the browser for interpretation and execution).

      Although JavaScript and Java are closely related, they are two different products developed by the two companies.
      Java is a new generation of object-oriented programming language launched by SUN company, especially suitable for Internet application development; while JavaScript is a product of Netscape company, its purpose is
to expand the functions of Netscape Navigator, and it can be embedded in Web pages. Object-based and event-driven interpreted language in Java, its predecessor is Live Script; and Java's predecessor is Oak language.
       The following is a comparison of the similarities and differences between the two languages:
  Object-based and object-oriented
  Java is a true object-oriented language, and objects must be designed even to develop simple programs. 
  JavaScript is a scripting language that can be used to make complex software that is network-independent and interacts with users. It is an object-based and event-driven programming language. Therefore, it provides a very rich internal object for designers to use. 
  Interpretation and Compilation
  The two languages ​​perform differently in their browsers. The source code of Java must be compiled before being passed to the client for execution, so the client must have an emulator or interpreter on the corresponding platform, which can compile the code independently of a specific platform through the compiler or interpreter 's bondage.
  JavaScript is an interpretive programming language. Its source code does not need to be compiled before being sent to the client for execution . Instead, the character code in text format is sent to the client for interpretation and execution by the browser. 
  Strong and Weak Variables
  The variables taken by the two languages ​​are different.
  Java uses strongly typed variable checking, that is, all variables must be declared before compilation. Such as: 
  Integer x; 
  String y;
  x=1234;
  x=4321;
  where X=1234 indicates an integer, and Y=4321 indicates a string.
  Variable declaration in JavaScript, using its weak type. That is, the variable does not need to be declared before use, but the interpreter checks its data type at runtime, such as:
  x=1234;
  y="4321";
  the former indicates that x is a numeric variable, while the latter indicates that y is a character type variable.
  The code format is different.
  Java is a format that has nothing to do with HTML. It must be loaded by referencing foreign media like HTML, and its code is stored in a separate document in the form of byte code.
  JavaScript code is a text character format that can be directly embedded in HTML documents and can be loaded dynamically. Writing HTML documents is as convenient as editing text files.
  Embedding is different
  In HTML documents, the two programming languages ​​are marked differently. JavaScript is marked with <Script>...</Script>, while Java is marked with <applet>...</applet>. 
  Static binding and dynamic binding
  Java uses static binding, that is, Java object references must be performed at compile time, so that the compiler can implement strong type checking.
  JavaScript adopts dynamic binding, that is, the object reference of JavaScript is checked at runtime. If it is not compiled, the check of the object reference cannot be realized.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325680615&siteId=291194637