Before we start learning about the Java programming language and start talking about Class, Object, variables, etcetera, we need to talk about code translator.
A code translator is a piece of code that the developer of the programming language creates. We know that we will be writing code in some programming language, and that code will make your computer do something. That is why we must understand how a computer will handle our code.
Let us take an example to understand
Let us say you are in a country where the English language is commonly spoken, and you only understand the English language. For some office or personal work, you visit a country where English is not used as a common language. Let us say the country you are in is China. You want to talk to a person, but you don’t understand Chinese at all. Normally, Chinese people know English as well, but let’s imagine that the person you want to talk to can only understand Chinese. Verbal communication will be impossible in this situation. You see around and find a person who can understand both languages, English and Chinese. It’s time to thank god because the person you just found can listen to you and translate that into Chinese and make the other person understand what you want to communicate.
In this example, the person you want to talk to is a Computer. The person you just found who can understand English and Chinese is a Code translator. I hope you understand the example.
The same thing happens in the programming world. The language you write your program in is called High-Level Language. The language that your computer understands is called Low-Level Langauge.
The examples of High-Level Languages are C#, C++, Java, HTML, etcetera.
An example of a Low-Level Langauge is Binary code. Your computer only understands Binary code, nothing else. When I say your computer, I mean your computer’s processor.
In Programming World there are Several Types of Code Translator
- Cross Compiler
These all are translators, but their working style is the key differentiator. We will talk about all of them one by one and understand their working style.
When we write a program in a programming language and give it to an interpreter, the interpreter reads Line 1, translates it, and then sends it for execution. Once Line 1 is executed without error. It starts reading Line 2 and translates it, and this process goes on until the entire program is not executed. Due to line by line translation style, interpreters are slow.
Unlike the interpreter, the compiler takes some time and compiles the entire program in one go, and sends it for execution. Because the compiler is not translating line by line, it is fast.
As we know, compiler and interpreter translate the High-level language code into low-level language code. The decompiler is just the opposite of compiler and interpreter. It takes low-level language code and translates it into high-level language code. You must be wondering why we need decompilers in the first place, but the decompilers are very useful. They are used in reverse engineering.
Have you ever wondered how an Antivirus scans all the files and tells you which one is infected or if you have any virus in your computer? An antivirus is basically a decompiler, and it scans all the files in your computer if it finds any executable code. The Executable code is a low language code. Changes the code into High-level code and then let the user know if the code is suspicious.
A compiler can generate a code that can run on another type of platform called Cross Compiler. For example, a program is made on a windows machine, which can run on the Linux platform. The compiler which is used to create such code is called Cross Compiler.
Now you know about how the computer, in very general terms, handles your code. Next, we will talk about Object-Oriented Programming concepts.
Do read our article on the history of Java.