What is the relationship between Javascript and Java?

藏色散人
Release: 2022-01-18 14:57:54
Original
7026 people have browsed it

Javascript has nothing to do with Java. JavaScript and Java are different products developed by different companies; JavaScript is a scripting language that runs in the browser, and Java is executed through interpretation. The language and syntax rules are similar to C.

What is the relationship between Javascript and Java?

The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.

What is the relationship between Javascript and Jave?

Javascript has nothing to do with Java.

1. What is Javascript?

It is a scripting language that runs in the browser. In web pages, Javascript can be said to be omnipotent:

 1. Can operate HTML, providing a tool to change HTML at runtime;

 2. Can attach and execute events, in line with the idea of ​​event-oriented programming;

 3 . Data verification function, verify the legality of the form data when submitting the form;

4. Operations on the customer's browser, such as forward, backward, refresh, jump, open a new window, print, etc.;

 5. You can create and use Cookies.

2. What is Java?

Java is a programming language launched by Sun. It is an interpreted language with syntax rules similar to C. At the same time, Java is also a cross-platform programming language. A program written in Java language is called an "Applet" (small application). After using a compiler to compile it into a class file, it is stored in the WWW page and marked accordingly on the HTML file. The client only needs to install Java The client software can run the "Applet" directly on the Internet.

Java is very suitable for corporate networks and Internet environments, and has now become one of the most popular and influential programming languages ​​on the Internet. Java has many commendable advantages, such as simplicity, object-oriented, distributed, interpretable, reliable, safe, structural neutrality, portability, high performance, multi-threading, dynamics, etc. Java eliminates various features in C that do more harm than good and many rarely used features. Java can run on any microprocessor, and programs developed in Java can be transmitted over the network and run on any client computer.

3. The origin of the name of Javascript

JavaScript was first called Mocha, which is the code name of this project. This name was used until the release of Netscape 2.0 beta 2 (95.11.04) - including the error box that popped up in beta 1, where the name Mocha can also be seen. However, as early as September 18th, netscape had announced that it would enable a server-side script (no name mentioned) in LiveWire. And because of the "front-end and back-end universal script" design we mentioned earlier, the language used the internal name LiveScript when beta 2 was released.

But what is equally confusing is that Netscape has actually decided to name the language "JavaScript" at this time. Therefore, the language is called JavaScript in the beta 2 release memo, but the interface has been changed from Mocha to LiveScript. This situation lasted until December 4, when netscape and sun jointly issued a statement officially launching the name JavaScript. Then beta 4 was released (95.12.20), and the interface and documentation were unified.

So in fact, the life cycle of the name "LiveScript" that can be verified is only one month (95.11.04-12.04). But after all, Mocha is just the project code name, not the product name, so later when people traced the history of JavaScript, most of them only mentioned LiveScript.

4. The difference between Java and Javascript

1. JavaScript and Java are different products developed by different companies. JavaScript is a product of Netscape. Its purpose is to expand the functions of Netscape Navigator and develop an object-based and event-driven interpreted language that can be embedded in Web pages; and Java is a new generation of object-oriented language launched by SUN Microsystems. Programming language, particularly suitable for Internet application development. In fact, the original name of javascript was not javascript, but LiveScript. The "Java" in the name was authorized by SUN Microsystems.

 2. JavaScript is object-based. It is a scripting language and an object- and event-driven programming language. Therefore, it itself provides a very rich set of internal objects for designers to use. Java is object-oriented, that is, Java is a true object-oriented language. Even when developing simple programs, objects must be designed.

 3. The embedding methods of javascript and Java are different. In the HTML document, the two programming languages ​​​​are identified differently. JavaScript uses Applet to identify it, while Java uses Applet to identify it.

 4. JavaScript and Java are executed differently in browsers. JavaScript is an interpreted 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. That is, the JavaScript statement itself is downloaded along with the Web page and is processed by the browser. Explanation and execution. The Java source code must be compiled before being passed to the client for execution. Therefore, the client must have an emulator or interpreter on the corresponding platform. It can be compiled independently of a specific platform through a compiler or interpreter. code.

 5. JavaScript and Java code formats are different. JavaScript code is an address format that can be directly embedded in HTML documents and can be loaded dynamically. Writing HTML documents is as convenient as editing text files. The format of its independent file is X.js. Java is a format that has nothing to do with HTML. It must be loaded like foreign media is quoted in HTML. Its code is saved in an independent document in the form of byte code. The format of its independent file is X.class.

6. The variables used by javascript and Java are different. The variable declaration in JavaScript adopts 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 strong type variable checking, that is, all variables must be declared before compilation.

7. JavaScript uses dynamic binding, that is, JavaScript object references are checked at runtime. Java uses static binding, that is, Java object references must be made at compile time so that the compiler can implement strong type checking.

8. JavaScript does not directly operate text and graphics. It works together with HTML element combinations in Web pages, but it can control the browser and allow the browser to directly process text and graphics. Java can directly operate on text and graphics.

Recommended study: "js Basic Tutorial"

The above is the detailed content of What is the relationship between Javascript and Java?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!