What is the difference between Java and Javascript?
This confusion is very common and just because they share the same prefix Java it is easy to think they are somehow related.
Java is a general programming language used heavily today for writing applications designed to run on desktops or servers. Although Java applications can be found in many areas, today many web applications are written with Java as the backend part.
Javascript is a programming language used heavily in web applications too, but found mostly at the frontend part. Although technologies like NodeJS allow you to write server-applications with Javascript. Usually there is a distinction between ‘server Javascript’ and ‘in-browser Javascript’. The important thing to remember is they’re still Javascript but for two different purposes.
In-browser Javascript
Here are some examples of what in-browser JavaScript is used for. Remember all is related to websites.
- Add or modify the HTML content of a page.
- Add or modify styles and visual aspects of a page.
- Add or modify behaviour, i.e what happens when a user clicks a button, text or anything else on the website.
- Examples of behaviour are also tracking mouse clicks and mouse movement. Even a keyboard press is possible to detect.
- Network related tasks like connecting to other server for fetching content.
- Manage those cute little cookies the browser stores
- Manage the data on the client-side, i.e. the browser.
Server Javascript
The applications with server Javascript are several. This is more related to system functionality as this type of Javascript is executed ‘near the server’. I.e. it is not concerned with the website of a user. But more about operating system related tasks. Examples of this would be
- Managing files on the hard drive
- Network handling
- Security of a server