Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
If the program is
error free then it converts the code of program into machine code and then the
program can be executed by separate commands. An interpreter checks the errors
of a program statement by statement.
Compiling
Example : C Compiler
Interpreting
Example : BASIC
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
First of all you need to understand that computers and humans speak different languages. While
humans speak languages like English, French, Hindi, Spanish, Chinese, Japanese, Arabic etc.;
computers speak only one language i.e. binary. Alphabet of computers contains only two letters,
namely zero and one. Computers are machines and for them it is much easier to work using a
simpler encoding of 0s and 1s.
We humans feel most comfortable if we could issue instructions by writing plain English or
Hindi programs for computers.
The problem is that we are not comfortable with binary and computers find our languages too
difficult to understand. To get around this problem a middle path of an intermediate language is
used to convey human commands to the computers. This intermediate language is called the
programming language.
Programming language is not plain English. It is essentially a predefined syntax of writing
logical computer instructions which humans can also understand.
We also need something to convert programming language into binary language for the
consumption by computer. This is where compiler comes in scene.
Compiler is a software that checks a computer program (called source code) and lists all the
errors found. When humans remove all these errors, compiler converts the program into binary
code (also known as machine code or object code). Computers can understand binary code and
therefore they can execute instructions written by humans using programming language.
Now we already know what a compiler does. Task of interpreter is also more or less the same but
interpreter works in a different fashion. The difference between the functioning of compiler and
interpreter will be clear from the table of comparison given below:
#
Compiler
Interpreter
Interpreter program works line-by-line. It
takes one statement at a time as
input.
code.
code.
Following image shows how different languages are either compiled or interpreted:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Java is Both a Compiled and Interpreted Language
Ah! Java is an amazing programming language. Designed originally by James
Gosling, this language encompass several innovative features. One of such features
is Java Virtual Machine (JVM). Also, Java is both a compiled and interpreted
language. When you write a Java program, the javac compiler converts your
program into something called bytecode. All the Java programs run inside a JVM
(this is the secret behind Java being cross-platform language). Bytecode compiled
by javac, enters into JVM memory and there it is interpreted by another program
called java. This java program interprets bytecode line-by-line and converts it into
machine code to be run by the JVM. Following flowchart shows how a Java program
executes.
hope this article helped you in understanding the concepts of compiler and
interpreter. If you have any further questions on the difference between compiler
and interpreter, please feel free to comment and ask me. I will most certainly try to
assist you. Thank you for using TechWelkin!