The difference between JavaScript and Java

Source: Internet
Author: User

One is a compiled language (the client platform must have an emulator or interpreter), and one is a parsed language (without compiling, directly sending text-formatted character codes to the browser to interpret the execution).

Although JavaScript is closely linked to Java, it is the two different products developed by the two companies.
Java is a new generation of object-oriented programming language from Sun, which is especially suitable for Internet application development, and JavaScript is the product of Netscape company, which is designed to
Extended Netscape Navigator functionality, and developed an object-based and event-driven interpretive language that can be embedded in Web pages, formerly known as Live Script, whereas Java was formerly the Oak language.
The following comparisons are made between the two languages:
   Object-based and object-oriented
Java is a true object-oriented language, and even if you are developing a simple program, you must design the object.
JavaScript is a scripting language that can be used to create complex software that is independent of the network and interacts with the user. It is a programming language based on objects (object Based) and event-driven events Driver. Thus it itself provides a very rich interior object for designers to use.
   Interpreting and compiling
The two languages do not perform the same way in their browsers.The source code of Java must be compiled before it is passed to the client for execution .As a result, the client must have an emulator or interpreter on the appropriate platform, which can be used by compilers or interpreters to implement code that is independent of a particular platform.
   JavaScript is an explanatory programming language whose source code does not need to be compiled before it is sent to the client for executionInstead, the text-formatted character code is sent to the client to be interpreted by the browser for execution.
   strong variables and weak variables
The variables taken in both languages are not the same.
Java uses strongly typed variables to check that all variables must be declared before they are compiled. Such as:
Integer x;
String y;
x=1234;
x=4321;
Where the x=1234 description is an integer, the y=4321 description is a string.
A variable declaration in JavaScript with its weak type. That is, the variable does not need to be declared before it is used, but rather the interpreter checks its data type at run time, such as:
x=1234;
Y= "4321";
The former indicates that x is a numeric variable, while the latter indicates that Y is a character variable.
   code format not the same
Java is an HTML-independent format that must be loaded by referencing an external media like HTML, and its code is stored in a separate document in the form of a byte code.
JavaScript code is a text character format that can be embedded directly into an HTML document and dynamically loaded. Writing an HTML document is as easy as editing a text file.
   not embedded in the same way
In an HTML document, the identities of the two programming languages are different, JavaScript uses <Script>...</Script> to identify, and Java uses <applet>...</applet> to identify.
  static and dynamic linking
Java uses static linking, meaning that Java object references must be made at compile time, so that the compiler can implement strong type checking.
JavaScript uses dynamic linking, in which JavaScript object references are checked at run time and cannot be checked for object references without compiling.

The difference between JavaScript and Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.