deferance between Compiler & interpretor

Programming & Compiler topics
Post Reply
User avatar
Face
Major
Major
Posts: 727
Joined: Thu Feb 18, 2010 5:06 pm
Location: SRI LANKA.KANDY.

deferance between Compiler & interpretor

Post by Face » Sun May 09, 2010 8:23 am

deference between Compiler & interpretor

can you explain what is the defrence between these two.I know only these facts.
These 2 are translators & compiler makes source program in to object program then in to execution.But interpreter makes source program in to object program.

*compiler
source program------------>object program------------>exe

*interpretor
source program------------>object program

then what is the use of interpretor...?It is like a half journey.

(friends I post my question according to my knowledge.I am a self learner.Soo my knowledge is not a proper one.If there are any wrong idea in my post please explain them..It may be a great help for me.)
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: deferance between Compiler & interpretor

Post by Neo » Mon May 10, 2010 12:29 am

Programmers usually write programs in high level code which the CPU cannot execute. So this source code has to be converted into machine code. This conversion is done by a compiler or an interpreter. A compiler makes the conversion just once, while an interpreter typically converts it every time a program is executed (or in some languages like early versions of BASIC, every time a single instruction is executed).

Compiler
A compiler is a computer program (or set of programs) that transforms source code written in a computer language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.

The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language or machine code).
Compiler.png
Compiler.png (27.73 KiB) Viewed 4956 times
Interpreter
In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language. An interpreter may be a program that either
  1. executes the source code directly
  2. translates source code into some efficient intermediate representation (code) and immediately executes this
  3. explicitly executes stored precompiled code made by a compiler which is part of the interpreter system
Most of the common languages used today such as C#, VB.Net, Java use a hybrid of compiler and interpreter techniques as in (3) above. These languages are usually compiled to a virtual machine code called bytecode first. At runtime, the bytecode is either interpreted or compiled to native code.
Post Reply

Return to “Programming Languages & Compiler Theory”