Types of Code Translator

Before we start learning about the Java programming language and start talking Class, Object, variables etcetera, we need to talk about code translator.

A code translator is a piece of code that is created by the developer of the programming language. We know that we will be writing code in some programming language and that code will make your computer do something. That is why it is important we understand how our code will be handled by a computer.

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 just imagine for this Example, 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. Its 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, as well as 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.

The example of 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

  • Interpreter
  • Compiler
  • Decompiler
  • Cross Compiler
  • Transpiler

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.

Interpreter

When we write a program in a programming language and gives this code to an interpreter. The interpreter reads Line 1 and 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.

Compiler

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.

Decompiler

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 a high-level language code. You must be wondering why do 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, 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.

Cross Compiler

When a compiler is able to generate a code that can run on another type of platform is called Cross Compiler. For Example – A program is made on a windows machine and that program can run on the Linux platform, the compiler which is used to create such code is called Cross Compiler.

Transpiler

Transpiler is a type of Compiler that compiles the code of one programming language and generate the code that is of another programming language. For Example – You write a program in TypeScript and compile the code with Transpiler, the Transpiler will generate the code of JavaScript.

Now you know about how your code is handled by the computer in very general terms. Next, we will talk about Object-Oriented Programming concepts.

Do read our article on the history of Java.

The post Types of Code Translator appeared first on LinuxAndUbuntu.



from LinuxAndUbuntu https://ift.tt/2YSLpKW

Post a Comment

0 Comments