The difference between Java and JavaScript

Author : xuzhiping   2023-02-13 16:20:46 Browse: 870
Category : JavaScript

Abstract: In various web page production technology forums, people often ask what is the difference between javascript and Java, and some ...

In various web page production technology forums, people often ask what is the difference between javascript and Java, and some even mistakenly believe that javascript is Java. Javascript and Java do have a certain connection, but they are not as close as we think, and even can be said that they are quite different.

Java and JavaScript

JavaScript is an implementation of ECMA 262 language specification. The purpose of this tutorial is to guide you to learn how to use JavaScript. All examples have passed under Internet Explorer 5. I have not tested them in various versions of Netscape browsers, so some examples may not run smoothly in Netscape browsers.

Java is a programming language launched by Sun Corporation. It is a language executed by interpretation, and its syntax rules are similar to C++. At the same time, Java is also a cross-platform programming language. Java is very suitable for enterprise networks and Internet environments, and has become one of the most popular and influential programming languages in the Internet.

Javascript differs from Java in the following aspects

1.Javascript and Java are different products developed by different companies.

Javascript is a product of Netscape. Its purpose is to extend the functions of Netscape Navigator, and develop an object-based and event-driven explanatory language that can be embedded in Web pages;

Java is a new generation of object-oriented programming language launched by SUN Microsystems, which is especially suitable for Internet application development. In fact, the original name of javascript is not javascript, but LiveScript. The "Java" in the name is authorized by SUN Microsystems.

2. Javascript is object based.

It is a scripting language, and it is an object-based and event-driven programming language, so it itself provides a very rich internal object for designers to use. Java is object oriented, that is, Java is a true object oriented language. Even developing simple programs must design objects.

3.Javascript and Java execute differently in browsers.

Javascript is an interpretive 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 text format to the client, that is, the javascript statement itself is downloaded along with the Web page and interpreted and executed by the browser.

The source code of Java must be compiled before being delivered to the client for execution, so the client must have an emulator or interpreter on the corresponding platform, which can compile code independently of a specific platform through the compiler or interpreter.

4.The format of javascript is different from that of Java code.

The code of javascript is a kind of address format, which can be directly embedded in HTML documents, and can be loaded dynamically. Writing HTML documents is as convenient as editing text files. Its independent file format is *. js.

Java is a format independent of HTML. It must be loaded by referencing external media in HTML. Its code is saved in a separate file in the form of bytecode. The format of the independent file is *. class.

5.The variables adopted 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 strongly typed variable checking, that is, all variables must be declared before compilation.

6.The variables adopted by javascript and Java are different.

That is, javascript object references are checked at runtime. Java uses static binding, that is, Java object references must be made at compile time to enable the compiler to implement strong type checking.

7.Javascript does not directly operate on text and graphics.

It plays a role in combination with HTML elements in Web pages, but it can control the browser to directly process text and graphics. Java can operate on text and graphics directly.

To sum up, we can find that although both javascript and Java can be applied to web page design, they do have too big differences. They are basically two languages.

Label :
    Sign in for comments!
Comment list (0)

Powered by TorCMS (https://github.com/bukun/TorCMS).