0% found this document useful (0 votes)
46 views

Difference Between Compiler and Interpreter: What Is A Compiler?

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Difference Between Compiler and Interpreter: What Is A Compiler?

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

 

Vitamin Zindagi: An Inspirational Story

Difference between Compiler and Interpreter ONLINE TOOLS


All Tools
Learn the main differences between compiler and interpreter. This article tells you Mobile Number Info
how source code converts into machine code and bytecode. Both compiler and
Font Converters
interpreter take a different approach for this conversion.
Type in Hindi

Email Address Extractor


“What is the difference between compiler and
interpreter?”, this used to be one of the often asked Hashing Tools
SPONSORED SEARCHES question during my computer science courses. If you’re
Base64 Decode
compiler vs interpreter memory learning programming, you would definitely need to
Base64 Encode
compare compiler vs. interpreter and learn the
c++ compiler
difference. Unfortunately, most of the computer
free learning courses science students tend to just mug up the answer RECENT STORIES

why compiler requires more memory without truly understanding the concept. Even a few What Is Aarogya Setu App? How it
teachers don’t know the concept of compiler and Works and how to install it?
all language compiler
interpreter so well as to teach their students! Cool Instagram Usernames for Girls
This morning, while speaking with one of my team and Boys
members, I once again remembered this classic Best Custom Robots.txt File for
compiler vs. interpreter comparison and I immediately decided to write a small piece about it. This Blogger/Blogspot
article will be useful for all the programmers wannabes.
Check Ticket Confirmation PNR
Status on WhatsApp

Easily Capture Screen and Do


What is a Compiler?
Recording on iPhone / iPad
First of all you need to understand that computers and humans speak different languages. While Consistent Video Upload is
humans speak languages like English, French, Hindi, Spanish, Chinese, Japanese, Arabic etc.; Important for YouTube Channel
computers speak only one language i.e. binary. Alphabet of computers contains only two letters,
Conditions for YouTube Channel
namely zero and one. Computers are machines and for them it is much easier to work using a
Monetization
simpler encoding of 0s and 1s.
How to Get Your First 100 and 1000
We humans feel most comfortable if we could issue instructions by writing plain English  or Hindi
Subscribers on YouTube
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.

Source code and assembly code.

The following video will further help you in understanding the concept and working of a compiler:

What a Compiler Is

Compiler vs. Interpreter


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

1 Compiler works on the complete program at Interpreter program works line-by-line. It takes
once. It takes the entire program as input. one statement at a time as input.

2 Compiler generates intermediate code, called Interpreter does not generate intermediate
the object code or machine code. object code or machine code.
3 Compiler executes conditional control Interpreter execute conditional control
statements (like if-else and switch-case) and statements at a much slower speed.
logical constructs faster than interpreter.
Compiled programs take more memory Interpreter does not generate intermediate
4 because the entire object code has to reside object code. As a result, interpreted programs
in memory. are more memory efficient.
Compile once and run anytime. Compiled Interpreted programs are interpreted line-by-line
5 program does not need to be compiled every every time they are run.
time.

Errors are reported after the entire program Error is reported as soon as the first error is
6 is checked for syntactical  and other errors. encountered. Rest of the program will not be
checked until the existing error is removed.

 7 A compiled language is more difficult to Debugging is easy because interpreter stops


debug. and reports errors as it encounters them.

 8 Compiler does not allow a program to run Interpreter runs the program from first line and
until it is completely error-free. stops execution only if it encounters an error.

Compiled languages are more efficient but Interpreted languages are less efficient but
 9 difficult to debug. easier to debug. This makes such languages an
ideal choice for new students.

Examples of programming languages that Examples of programming languages that use


10 use compilers: C,  C++, COBOL interpreters: BASIC, Visual Basic, Python, Ruby,
PHP, Perl, MATLAB, Lisp

Following image shows how different languages are either compiled or interpreted:

Difference between compiler and interpreter.

Difference between Compiler and Interpreter


So, what did we understood from the above table of comparison? We now know that the reason a
compiled runs faster because it gets converted into machine code all at once. Computer can easily
understand machine code and therefore can run the whole program quickly. But this also means that
the entire compiled code has to reside in the memory —and thereby making the compiled programs
more memory guzzling. With memory available in abundance, nowadays, this is no longer a concern.
But in earlier days of programming, when memory was an expensive resource, program size up to
every bit and byte used to matter.

In comparison, interpreter is a more human-friendly program. It works quite a bit like humans work.
It begins program execution right at the first line and will go on showing you the result of the program
until it will hit an erroneous line of code. As a result, for programmer it is much easier to locate error
and to understand the nature of error. However, interpreter is slow. An interpreted programs gets
interpreted every time it runs.

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.

Execution of a Java program. Java is both a compiled and interpreted language.


I 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!

RELATED ARTICLES FOR MORE INFORMATION:

1. Hindawi: Write Computer Programs in Indic Langauges

2. Building Strings in Java

3. Java Memory Management: Heap Space and Garbage Collector

4. Difference between Static and Dynamic Web Pages

5. Blog vs Website: Difference Between Website and Blog

. Difference Between CDMA and GSM Mobiles Phones

Last updated: 10 March 2017 | Published on: 25 June 2015 | Authored and Edited by: Lalit Kumar
and Team | Filed as: Home » Programming » Difference between Compiler and Interpreter

Lalit Kumar is the Principal Author and Founder of TechWelkin. He is a web


explorer and he enjoys finding useful information on the Internet. He loves to
put things together to create a bigger solution. Lalit is passionate about
technology, languages and literature. You can contact Lalit via email
(techwelkin [at] gmail [dot] com) or Facebook (facebook.com/techwelkin).

Comments

Mo Savage says

You explain it like drinking water, please keep up the good job

Reply

sailoranchor says

perfect explanation!! thanks a lot

Reply

mansi says

i have a few doubts regarding interpreter.it is written that interpreter does not generate an
intermediate machine code but later on in the last para it is written that interpreter interprets byte
code lineby line and generated machine code.so the interpreter is also generating machine code
and compiler also generates machine code which is here called intermediate code.so whats the
difference ??

Reply

Amr Saeed says

Thank you for the great explanation!

Reply

Abu AmatuLlah says


awesomely explained
you have saved my day

Reply

nagesh says

Hi sir,

Thanks for explaining the concept in very simple way.

I have few questions here ,when you say that the compiler will produce INTERMEDIATE machine
code as per the difference 2 why is it referred as intermediate?

Its ultimately the machine code which is the final format that the underlying platform
understands right ?

If interpreter is not generating machine code then what is its output/interpreted result?

Reply

Lalit Kumar says

Code produced by compiler is often called intermediate code because that code may still
go through further medications (such as optimization) before becoming ready for
execution on the target machine.

Reply

Clash says

Why does java use both and what gets put into just in time compiler and java interpreter, that
requires both of them? Is is because some of the bytecode is faster through the compiler but not
all of it so it uses the interpreter or why?

Reply

thriveni says

thanks for sharing knowledge

Reply

Abhinav Kumar says

Sir,
Thanks a ton….
It was really helpful and brilliantly elaborated. Cleared a lot of doubts especially with respect to
java.
I would like to know about the role of Just In Time (JIT) Compiler.
And, I am a beginner in Java , so if could kindly give me any contact of yours where I can clear my
doubts, it would be of great help.

Reply

Jeet Sengupta says

Very nicely explained. I got my doubts cleared. Thank you for this article.

Reply

K Mukesh Mahadev says

The most straight and necessary information provided.


Thanks a lot Sir!!!
The last part about java is now very clear to me.

Reply

Fanía says
Best explanation ever, thank you so much, really.

Reply

ifeanyi says

I love your explanations. it helped me a lot.

Reply

Anshuman says

Thank You very much Sir. My question is : Are compiler and interpreter are inbuilt with windows
operating system or we have to install both the software separately. If they are inbuilt with
windows OS , then how to select one from both to check a source code.

Reply

Lalit Kumar says

A compiler or interpreter comes as a package when you install a development


environment for a programming language. For example, when you install Microsoft Visual
Studio or Turbo C etc. the required compiler / interpreter also get installed.

Reply

Santana Adhikary says

Sir, this article very helpful for understanding the difference between compiler and interpreter…
Thank u so much..

Reply

Sandeep Shrivastava says

Nice article …really helped me a lot …keep writing articles like this. It is the best explanation of
compiler and interpreter read by me till now..

Reply

kabare says

Thank you for helping and to improve our skills.

Reply

saba says

Best explination as thanks:-)

Reply

Mao says

Best explanation ever. Thanks.

Reply

Moiht says

Thank You Sir for this useful article.


But I want to ask, Compiler and Interpreter are System Software or Application software??

Reply

Lalit Kumar says

Hi Mohit, compiler and interpreter do not really fit in the definition of system of application
software. But if you have to categorize, then I would say that compiler is more like an
application software because it does not play role when the compiled program is
executing. In contrast, the continuous need of interpreter during execution makes it more
like a system software.
Reply

Muhammad Adnan says

Both are system softwares…

Reply

Danish says

Dear Sir I am very thankful to you.

You did a great job and your language is simple to understand. It doesn’t seem that it’s written in
English; it’s like our mother tongue. Now I can differentiate very well between interpreter n
compiler and tell anyone. As you said most of the teachers don’t know about this. You are
absolutely right. Once again thanks a lot sir n keep doing this job.

Reply

Lalit Kumar says

Thank you Danish! I am happy that this article helped you in understanding the difference.
All the best for your future. Stay tuned with TechWelkin!

Reply

Dinesh Verma says

Thanks for the article. But, I have a small question – Why people say that compiled programs are
faster than interpreted ones?

Reply

Lalit Kumar says

Good question, Dinesh! As I said in the article, interpreted programs needs to be


interpreted everytime they run. That makes them slower. Also interpretation of conditional
control statements is slower. In contrast, compiled programs get converted into ready-to-
run binary code at the time of compilation. As a result, compiled programs run faster.

Reply

mansi says

If the compiler is fast enough then why do we need to use interpreter even if both
do the same task.

Reply

qods says

Just for your encouragement: I appreciate and thank you very much for the information.

Regards.

Reply

Lalit Kumar says

Thank you for taking time out to write your kind words. I am glad that this article turned
out to be useful for you. Stay connected with TechWelkin!

Reply

Sharad Singh Sankhla says

जय श्री कृ णा
लिलिलत जी मै कं यूटर की A B C D भी नहीं जानता पर आपने जो िलखा उसे पढ़कर यह समझ सकता हू ँ िक ये जानकारी बहुत ही
उपयोगी है .

Reply
Shyamal Kumar Das says

Sir,

I worked as a programmer for 15 years, without having such a through knowledge about
compilers and interpreters. Simply I wrote programs in Clipper and compiled them to executable
files after proper linking.

Thank you very much for the knowledge, you shared.

Regards.

Reply

Lalit Kumar says

Shyamal, I am glad that you liked the article! Thank you for your comment. Stay connected
with TechWelkin!

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment

Name *

Email *

Website

Post Comment

Tools Connect with us


Hindi Proof Reader Facebook
Top Tech Blogs in India Twitter
QR Code Generator LinkedIn
Random Word Generator Pinterest
Strong Password Generator RSS Feed
Trace Mobile Numbers

© 2007-2021 TechWelkin.
The content is copyrighted to Lalit Kumar and may not be reproduced on other websites.
TechWelkin displays Google AdSense ads. See how Google uses data when you're on TechWelkin | Privacy Policy

You might also like