I wrote this article because I saw someone asking this question on Zhihu, and I wondered how such an SB question could exist, but then I thought about how the SB me back then also seemed unable to figure out the relationship between the two; cognition requires a process.
Then I saw some classic answers: the relationship between Java and Javascript is like the relationship between Lei Feng and Leifeng Pagoda, and also like the relationship between wife and wife cake.
It is generally believed that the reason Netscape named LiveScript as JavaScript at that time was because Java was the most popular programming language at the time, and having the name "Java" helped the spread of this new language.
Their similarities include:
- Their syntax is very similar to the C language;
- They are both object-oriented (although implemented in slightly different ways);
- JavaScript referred to Java's naming conventions in its design;
Their differences include:
- JavaScript is a dynamically typed language, while Java is a statically typed language;
- JavaScript is weakly typed, while Java is strongly typed;
- JavaScript's object-orientation is implemented based on prototypes (prototype-based), while Java is based on classes (class-based);
Apart from looking somewhat like Java, JavaScript's language style is very different. The languages referenced in JavaScript's design did not include Java, but included languages like Self and Scheme.