Advertisements

Difference Between Java and Javascript

It is quite common that you tend to think that Java and Javascript are similar, because they share the same initial word of their names, even many people think that Javascript is a part or a derivation of Java, something that is really far from reality, let’s see why.

Advertisements

It is quite common that you tend to think that Java and Javascript are similar, because they share the same initial word of their names, even many people think that Javascript is a part or a derivation of Java, something that is really far from reality, let’s see why.

Let’s take a bit of wikipedia and similar content to give a “historical” context before going into more technical matters.

Java

It is an object-oriented programming language created in the early nineties of the twentieth century by the company Sun Microsystem and acquired by Oracle in 2010 in order to offer programmers the ability to write the code only once and can run it on any device; for this Java Virtual Machine – JVM was developed that makes the language portable to all platforms.

JavaScript

It was created in the middle of that decade by the company Netscape in order to provide greater interactivity to web pages viewed with Netscape Navigator, a web browser owned by the company and leading the market at that time; The Java word used at the beginning of the name was a strategy to take advantage of Java marketing at that time.

Both languages ​​except for the similarity of the word Java in their names are quite different; Then we will show some of the most notable differences between both languages:

Java is a compiled language and JavaScript is interpreted

The first big difference we get between both languages ​​is that Java is compiled and JavaScript is interpreted; to be able to understand it in a more basic way, it can be said that programs made in Javascript are text files that can be read by both computers and people, while Java programs after being written must be compiled.

The compilation creates an optimized file that can be read and executed by the operating system of the computer; Java programs are compiled in bytecode, an intermediate language that can only be interpreted by a JIT run that allows it to be multiplatform.

Purification Phases

In Java the debugging is done in two phases, while in Javascript it is done in a single phase, this implies that in this language only the programmer notices if there are syntax errors at the time the program is executed to perform a test, although it is worth noting that you can use specialized tools that allow you to interpret the code in the background, including Visual Studio.

While in Java it is necessary to perform the compilation phase first, in this phase the compiler indicates the syntax errors that exist, which must be corrected in order to make a successful compilation; so when the program is executed there will be no syntax errors, however logic or other errors may occur.

Versatility

Java is an object-oriented programming language, while Javascript is based on prototypes, so it must simulate a large number of object-oriented features that most languages ​​possess; However, it offers several programming paradigms that make it an extremely versatile language.

Flexibility

Java is a strongly typed language that does not allow changes or violations in the defined data types, that is, the variables must be of a defined type and once they have been declared they can not be changed, which makes it a language not very flexible.

In Javascript, because it is a weak typing language, a variable can contain different types of data, which makes it a very flexible language, but this quality also causes many errors if you do not have enough care when writing and structure the code.

Advertisements

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: