Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,158,176 members, 7,835,928 topics. Date: Tuesday, 21 May 2024 at 05:39 PM

Compiler Vs Interpreter Difference - Technology Market - Nairaland

Nairaland Forum / Science/Technology / Technology Market / Compiler Vs Interpreter Difference (319 Views)

(2) (3) (4)

(1) (Reply)

Compiler Vs Interpreter Difference by tutusaint(m): 12:33pm On Jul 13, 2015
Learn the main differences between compiler and interpreter. This article tells you how source code converts into machine code and bytecode. Both compiler and interpreter take a different approach for this conversion.
“What is the difference between compiler and interpreter?”, this used to be one of the often asked question during my computer science courses. If you’re learning programming, you would definitely need to compare compiler vs. interpreter and learn the difference. Unfortunately, most of the computer science students tend to just mug up the answer without truly understanding the concept. Even a few teachers don’t know the concept of compiler and interpreter so well as to teach their students!
This morning, while speaking with one of my team members, I once again remembered this classic compiler vs. interpreter comparison and I immediately decided to write a small piece about it. This article will be useful for all the programmers wannabes.

What is a Compiler?

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.

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.

Source Greentechn Blog

(1) (Reply)

Used Bold 6 For Sale / $25 Bestbuy Gift Card For Sale At The Rate Of #4000 / Very Clean Blackberry Passport For Sale Call 08083817074

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.