Although Javascript is closely related to Java, it is two different products developed by two companies. Java is a new generation of object-oriented programming language launched by Sun. Especially suitable for Internet application development; Javascript is a product jointly launched by Sun and Netscape. It is an object-driven interpreted language developed to extend the Netscape Navigator functionality that can be embedded in Web pages. And its predecessor was Live Script, while Java's predecessor was Oak language. Here is a comparison of the similarities and differences between the two languages:
(1) Object-based and object-oriented
Java is a truly object-oriented language, and even when developing simple programs, objects must be designed. Javascript is a scripting language that can be used to create complex software that is non-network-related and implements user interaction. It is an Object-based and Event Driver programming language. Therefore, it itself provides a very rich internal object for designers to use.
(2) Explanation and translation
The two languages execute differently in their browsers. Java source code must be compiled before being passed to the client for execution, so there must be a */ interpreter or interpreter running on the corresponding platform on the client. It can be achieved through a compiler or interpreter independent of a particular platform and not bound by compiled code. Javascript is an interpreter programming language. Its source code does not need to be compiled before being sent to the client for execution. Instead, it sends character code in text format to the client and interprets and executes by the browser.
(3) Strong variables and weak variables
The variables used in the two languages are different. Java uses strongly typed variables, that is, all variables must be declared before compilation. like
Integer x;String y;x=1234;x=4321;
Where x=1234 means an integer, Y=4321 means a string.
In JavaScript, weak types are used, that is, variables do not need to be declared before use, but the interpreter checks their data types at runtime, such as
x=1234;y="4321";
The former means x is its numerical variable, while the latter means y is a character variable.
(4) The code format is different
Java is a HIML-independent format that must be loaded like references to external media in HTML, and its code is saved in a separate document in the form of byte code. JavaScript's 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.
(5) The embedding method is different
In HTML documents, the two programming languages have different identifications. JavaScript uses "<Script Language="JavaScript">" to identify, while Java uses "<applet>...</applet>" to identify.
(6) Static linkage and dynamic linkage
Java adopts static typing, that is, Java's object reference must be performed at compile time to enable the compiler to implement strong type checking. JavaScript adopts dynamic linkage, that is, JavaScript object references are checked at runtime. If they are not compiled, the object reference inspection cannot be implemented.
JavaScript is embedded in HTML and becomes part of HTML documents.
What is the relationship between Javascript and Java language mentioned above? I hope the comparison of similarities and differences between the two languages will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!