Home > headlines > Understand the difference between JavaScript, Java, and PHP in one article

Understand the difference between JavaScript, Java, and PHP in one article

阿神
Release: 2017-03-15 10:45:41
Original
29139 people have browsed it

The practice of website development starts with the design aspects, including client-side programming languages. Broadly speaking, three languages ​​are used in web design: HTML, CSS and JavaScript. HTML and CSS have been the foundation of web design since the invention of websites, but JavaScript is used to add dynamic views to websites.

JavaScript plays a vital role in providing attractive UI/UX. However, there is a big misconception about JS being part of Java. Sometimes, JavaScript is also compared to the server language PHP.

Today we will discuss the comparison between JavaScript and java and JavaScript and PHP. This will make you realize the similarities and differences between them.

Understand the difference between JavaScript, Java, and PHP in one article


#The relationship between JavaScript and Java

First of all, it must be clear that the history of

Understand the difference between JavaScript, Java, and PHP in one article

javascript

## "In 1994, Netscape released Navigator browser version 0.9. This was the first relatively mature web browser in history and became a sensation. However, this version of the browser could only be used for browsing and did not have The ability to interact with visitors...Netscape urgently needs a web scripting language that allows browsers to interact with web pages.

What is the web scripting language? Netscape had two options at the time: one was to use existing languages, such as Perl, Python, Tcl, Scheme, etc., and allow them to be directly embedded into web pages; the other was to invent a completely new language.
  1. Both options have pros and cons. The first option is conducive to making full use of existing code and programmer resources, and is easier to promote; the second option is conducive to developing a fully applicable language, and is easier to implement.

    Netscape was internally arguing over which option to adopt, and management was unable to make up its mind.
2. At this time, another major event happened: in 1995, Sun changed the name of Oak language to Java and officially launched it to the market.

Understand the difference between JavaScript, Java, and PHP in one article With Sun's much-hyped promise that the language could be "Write Once, Run Anywhere" (Write Once, Run Anywhere), it seemed likely to dominate the future.

Netscape was moved and decided to form an alliance with Sun. It not only allows Java programs to run directly in the browser in the form of applets (small programs); it even considered embedding Java directly into web pages as a scripting language, but it was only because this would make HTML web pages too complex that it had to be abandoned later.

In short, the situation at that time was that the entire management of Netscape was a believer in the Java language, and Sun was completely involved in the decision-making of web scripting languages. Therefore, Javascript was later brought to the market jointly by Netscape and Sun. It is not accidental that this language is named "Java+script".

3. At this time, 34-year-old system programmer Brendan Eich appeared. In April 1995, Netscape hired him.

Brendan Eich's main direction and interest is functional programming. Netscape recruited him to study the possibility of using Scheme language as a web scripting language. Brendan Eich himself thinks this way, thinking that after entering a new company, he will mainly deal with the Scheme language.

Understand the difference between JavaScript, Java, and PHP in one article

Just one month later, in May 1995, Netscape made a decision that future web scripting languages ​​must "look similar enough to Java" but be simpler than Java so that non-professional web page authors can get started quickly. This decision actually excludes non-object-oriented programming languages ​​such as Perl, Python, Tcl, and Scheme.

Brendan Eich was designated as the designer of this "simplified version of the Java language".

4. However, he has no interest in Java at all. In order to cope with the tasks assigned by the company, he designed Javascript in only 10 days.

Because the design time was too short, some details of the language were not considered rigorously enough. As a result, the programs written in Javascript were chaotic for a long time. If Brendan Eich had foreseen that this language would become the number one language on the Internet in the future, with millions of learners around the world, would he have spent a little more time?

Understand the difference between JavaScript, Java, and PHP in one article In general, his design ideas are as follows:

(1) Learn from the basic syntax of C language;

(2) Learn from the data types and memory management of Java language;

(3) Learn from the Scheme language and elevate functions to the status of "first class citizens";

(4) Learn from the Self language and use the inheritance mechanism based on prototype.

Therefore, the Javascript language is actually a mixture of two language styles - (simplified) functional programming + (simplified) object-oriented programming. This was a joint decision between Brendan Eich (functional programming) and Netscape (object-oriented programming).

The similarities between javascript and java

OOPS (object-oriented programming) concept
These two languages All follow the OOPS (Object-Oriented Programming) concept. You already know about working with objects in Java. Similarly, in JS, objects are the same as the relationships between them.
Front-end development
Among them, JavaScript can be added directly to HTML, and Java can also be used as a Java Applet (Java applet).

The difference between javascript and java

Running platform
Java requires a JDK or JRE JVM (Java virtual machine). JavaScript, on the other hand, runs on the web browser and therefore does not require a specific platform. Interestingly, all recent web browsers support JavaScript.
Scope
In terms of availability, Java is available everywhere and is also considered an independent programming language. JavaScript, on the other hand, is limited to use with HTML and CSS; its global use is resisted.
Compilation
Java is a compiled and interpreted language, while JavaScript is just a plain text code. This means that code written in JS is interpreted on different platforms.
Constructor
Constructor is used for object creation in Java, while in JS, the constructor is just a standard function.


##The relationship between JavaScript and php

JavaScript and PHP are two of the most popular programming languages ​​at present.

Understand the difference between JavaScript, Java, and PHP in one article

JavaScript is similar to PHP

The battle between JavaScript and PHP is more important because both languages ​​are a major part of web development.


Usage scopePHP (Hypertext Preprocessor) and JavaScript, for web development tasks. Their unparalleled importance helps coders build powerful backend functionality and attractive user interfaces.

Interpreted Languages Both PHP and JavaScript are called interpreted languages ​​(or scripts). This means that the code runs on its respective environment (browser and server for JavaScript and PHP respectively).

JavaScript is different from PHP
Server and clientBased on the front-end and back-end, these two languages ​​are different. JavaScript scripting language is a front-end language (except Node.js), while PHP is a server-side language.

ConcurrencyIn PHP, the concept of multi-threading can be used to handle multiple requests at the same time. On the other hand, in JavaScript, the encoder only provides some strategies like event loop + node clustering, which help in handling the same events.

OOPSAs mentioned before, JavaScript uses objects and the relationships between them when writing scripts. On the other hand, PHP is a procedural object-oriented language.

CompatibilityJS language can be embedded in HTML, XML and AJAX. PHP, on the other hand, can only embed HTML. It doesn't work with XML. However, there are other options for using the same with XML.
Therefore, it is relatively clear that the JavaScript scripting language is somewhat similar to Java and PHP, but it is not a language that can replace these languages. You can use JS as a supporting language, but you can't make it the base language for web-based or application-based coding.
The scope of JavaScript has been enhanced with the introduction of Node.js, Angular.js and other scripts. So, if you are a web developer, learning JavaScript will always be an advantage of your knowledge and skills.

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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template