It's not a surprise that when we begin to learn programming we confused these two languages, since they both have similarities in their names. But today we are going to understand what differentiates them and why we must learn not to confuse them. Let's start.
|It's need a virtual machine and a development kit to be able to work.||It's only need a text editor to work.|
|It's form of execution, as we saw in my previous post, places it in a language both compiled and interpreted, through the use of its JVM.||It's an interpreted language, as we also saw in my previous post.|
|In original nature it was mainly created to be used on the back-end side.||In original nature it was mainly created to be used on the front-end side.|
|It's methodology is based on classes within object-oriented programming.||It's methodology is based on prototypes within object-oriented programming.|
|It's strongly typed.||It's weakly typed.|
|It's debugged in two phases.||It's debugged in one phases.|
These are some of the main differences, there may be others in depth in both languages, but we will address the ones I have mentioned. If you can contribute more differences, feel free to add it and open a discussion, so we all learn much more.
Taking these differences in mind, will they have any characteristics in common? Yes, few, but there are.
- Both languages are C-based
- Both are cross-platform programming languages
- Both are languages that, due to their time on stage and wide community, are classified as robust languages.
Oracle is the private company in charge of this language. Today it's in JAVA SE 14 version.
Java is made up of different platforms:
Java SE (Standard Edition) is used to build desktop applications, console applications with Swing and JavaFX.
Java EE (Enterprise Edition) is used to develop web applications. It comes with many technologies.
Java ME (Micro Edition) is used to develop mobile applications.
As I also mentioned, in order to run a program in JAVA, you must first have installed the Java Development Kit, but what is this?.
The main tool that we can mention is the javac compiler, it allows compiling the .java source file and transforms it into a bytecode with .class extension. Another important tool to mention within the JDK is javadoc, which allows you to generate the documentation for the code. The JDK also includes the JRE, which is the Java runtime environment, that is, the place where the code is executed.
As its name implies, JDK is a tool used for development, so it is generally only used by the Java developer community, but not the end user. By contrast, the JRE is the tool that the end user needs to run their program or application.
But as a curious thing, the JDK cannot be installed without the JRE, however, the JRE can be installed independently. This makes sense, since as programmers we need to test our code, therefore we need their execution environment to be able to do it, while end users only need to execute it.
As we saw in my previous post (Classification of computer languages (III)), Java is a compiled language, but through its VM you can choose whether to interpret the bytecode or compile it. As we can visualize it in the previous image.
It's based on creating a mold structure called class where the fields and methods that our objects will have are specified. Every time we need an object we create an instance (or copy of the object) using the class as a template.
The concept refers to the strict use of data types when declaring variables or using parameters. Personally, it is a feature of languages like Java that are very useful to me, especially at the time of data entry by the user. Allows better control of input data.
It is also a very important feature when programming, since, knowing the types of data to be used from the beginning, you will have greater control when allocating the spaces in the memory of the data. If you are an intermediate programmer, you will know that an INT is not the same as a BYTE and the effects this has on the memory, weight and execution time of the code. Later I will talk about this in another post.
At the time of executing our java code, the debugging is done in two steps:
At compile time: When the javac compiler tries to generate the bytecode, it first parses the syntax, and if it is not correct, it warns of this error and the code doesn't execute.
At runtime: If the first step does not generate errors, the code is executed, but it may happen that the user enters an unexpected data type, or tries to access an index that does not exist in an array, or the basic errors in Java mathematical operations such as divisions by zero or saving strings where they should be numbers. The program runs, but at the time of finding one of these errors, it will hang and not work properly.
This is a very versatile language, since, although it is naturally based on prototypes, as I mentioned earlier, it easily adapts to other methodologies.
If our code is correct, the parser generates a structure known as AST or Abstract SyntaxTree. The syntax is "abstract" in the sense that it does not represent all the details that appear in the actual syntax, but only the structural or content-related details. This structure is translated into machine code and it is at this moment that the execution of our program actually occurs.
In this methodology there are no classes, only objects. To create an object with the same structure as another, the term object cloning is used. This cloning is done through a prototypical object, which is used as a template to obtain more objects equal to it.
For many programmers, this is an advantage, as it constantly eliminates thinking about what kind of data to use and focusing on logic. Another possible advantage is being able to change the type of the variable on the fly, such as assigning a string to an int.
As we can see, these languages cannot be confused, since their independent characteristics allow us to see that there is no reason for it. Remember, if you want to contribute more to this article, feel free to do so!
See you soon!