Differences between JavaScript and Java

Source: Internet
Author: User

Address: http://www.qeefee.com/js/difference-between-javascript-and-java

For more Javascript tutorials, visit> Javascript tutorials

Body:

Regarding the relationship between java and javascript, I once saw such a sentence in a forum. The relationship between java and javascript is like the relationship between Lei Feng and Leifeng tower. It is really classic!

Because of the relationship between names, some people often mistakenly think that Javascript is a subset of Java, or there will inevitably be some relationships. But we are very disappointed that these two programming languages have no internal relationship except the same name at the beginning!

What is Javascript?

In the previous Javascript introduction, I introduced what Javascript is. It is a scripting language running in a browser. on a web page, Javascript is omnipotent:

  • Attackers can operate on HTML and provide a tool to change HTML at runtime.
  • Events can be appended and executed to conform to the idea of event-oriented programming.
  • The data verification function verifies the validity of the form data when submitting the form.
  • Operations on the customer's browser, such as forward, backward, refresh, jump, opening a new window, and printing
  • Cookies can be created and used.
What is Java?

Java is a programming language launched by Sun. It is a language that is executed in an interpreted way. Its syntax is similar to that of C ++. Java is also a cross-platform programming language. A program written in Java is called an "Applet" (a small application). It is compiled into a class file by a compiler and stored on the WWW page, the user end can directly run the "Applet" on the Internet as long as Java client software is installed ".

Java is very suitable for enterprise networks and Internet environments. It has become one of the most popular and influential programming languages on the Internet. Java has many commendable advantages, such as simplicity, object-oriented, distributed, explanatory, reliable, secure, structure neutral, portability, high performance, multithreading, and dynamic. Java has abandoned the features that do more harm than advantage in C ++ and many rarely used features. Jave can run with any microprocessor. Programs developed using Java can be transmitted over the network and run on any client.

Origins of Javascript names

JavaScript was first called Mocha (magic card), and this is the code name of this project. This name is always used before the release of Netscape2.0 beta 2 (95.11.04)-including the pop-up error box in beta 1, you can also see the Mocha name. However, as early as September 18, netscape has published a message to enable a server-side script in LiveWire (name not mentioned ). Because of the design of the "General frontend and backend scripts" mentioned above, the language uses the internal name LiveScript when beta 2 is released.

But what is equally confusing is that, in fact, Netscape has decided to name the language "JavaScript ". Therefore, in the release notes of beta 2, the language is called JavaScript, but the interface is changed from Mocha to LiveScript. This situation continued until December 4. netscape and sun jointly issued a statement to officially enable the JavaScript name. Then beta 4 was released (95.12.20), and the interface and documentation were unified.

Therefore, in fact, the "LiveScript" name can be used to check the lifecycle, which is only one month (in 95.11.04-12.04 ). However, Mocha is only the project code name, not the product name, so people trace the history of JavaScript, most of which only mention LiveScript.

Differences between Javascript and Java

1. javascript and Java are different products developed by different companies. Javascript is a product of Netscape. It is designed to expand the Netscape Navigator function. It is an object-and event-driven explanatory language that can be embedded into Web pages; java is a new-generation object-oriented programming language launched by SUN Microsystems, which is especially suitable for Internet application development. In fact, the original javascript name is not javascript, but LiveScript. The "Java" in the name is authorized by SUN Microsystems.

2. javascript is based on objects. It is a scripting language and a programming language based on objects and events, therefore, it provides a wide range of internal objects for designers. Java is object-oriented, that is, Java is a real object-oriented language, and even simple programs must be designed.

Iii. javascript and Java are embedded in different ways. In HTML documents, the two programming languages have different identifiers. javascript uses <script> </script> for identification, while Java uses Applet for identification.

4. javascript and Java are executed in different ways in the browser. Javascript is an interpreted programming language. Its source code does not need to be compiled before it is sent to the client for execution. Instead, it sends the character code in the text format to the customer, that is, the javascript statement is downloaded along with the Web page and interpreted and executed by the browser. The source code of Java must be compiled before it is passed to the client for execution. Therefore, the client must have a simulator or interpreter on the corresponding platform, it can compile code independently from a specific platform through a compiler or interpreter.

5. the javascript and Java code formats are different. Javascript code is a website-specific format that can be directly embedded into HTML documents and loaded dynamically. It is just as convenient to compile HTML documents as editing text files, the format of the independent file is *. js. Java is an HTML-independent format. It must be loaded by referencing external media in HTML, and its code is saved as byte code in an independent document, the format of the independent file is *. class.

6. the variables used by javascript and Java are different. The variable declaration in javascript uses a weak type, that is, the variable does not need to be declared before use, but the interpreter checks its data type at runtime. Java uses a strongly typed variable check, that is, all variables must be declared before compilation.

7. javascript uses dynamic concatenation, that is, javascript Object Reference is checked during runtime. Java uses static concatenation, that is, Java object reference must be carried out during compilation, so that the compiler can implement forced type check.

8. javascript does not directly operate on text and graphics. It works with HTML elements in Web pages, but it can control browsers, allows the browser to process text and graphics directly. Java can directly operate on text and graphics.

Related Article

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.