compiler, interpreter and assembler

On a broader level any programming language are classified into three types:

  • Compiler Language
  • Interpreter Language
  • Assembly Language

Compiler Language:

C is one of the compiler language which works together with another program called compiler which takes the logic written by us and produces an object code or machine code that is executable file which can be executed later and it does our intended work.

Even our compiler are programs that processes our inputs/logic and converts them into machine language(executable) or code that a computer uses.

Few of the common compilers for C language are : GCC or Visual Studio

Interpreter Language:

One of the key difference between compiler and interpreter language, in case of compiler, our code is converted into machine code(.exe) before the program runs where as in case of interpreter

language, our code is converted into machine code when the program runs.

On the same not as compiler even interpreter is a program which does the job of converting higher level programming language to machine language.

One of the key example of such language is any scripting example like Python, Ruby or Perl.

Assembly language:

The major difference among compiler and interpreter language and assembly language is a low level language unlike the other two which is high level language. It is used primary used for direct hardware manipulation, to access any particular bits in the processor.

Its not a pure low level language and thus needs another language translator called assembler which converts it onto machine code.

Note:

The way programs are classified based on their feature are referred as Programming Language Paradigm.

Key difference between compiler and interpreter:

  • In case of compiler, the program is run after the machine code is generated whereas in case of interpreter the machine code for specific instruction is generated when the program is still running. That is generation of machine code and program runs in parallel.
  • In case of compiler the complete program at once is taken and generated the machine code which is run later to get the output whereas in case of interpreter instruction are taken line by line and converted to machine code and we get the output.
  • Compiler language are faster then interpreter as in case of interpreter the instruction are executed one by one unlike compiler where all the instruction are converted to machine code at once.
  • Compiler language are harder to debug but interpreter are easy as each instruction is run one by one unlike compiler where all the instruction are taken together and user sees all the errors at once.
  • Compiler language takes more memory to store the object code as separate file is created unlike for interpreter where interpreter directly gives the output.
  • In case of compiler once the object code is created the source file and compiler is not required to run it again n again but not same for interpreter language.

All these three compiler, interpreter and assembler are language translator

Real life example:

Interpreter: Conversion of one language into another after each statement.

Compiler: Any movie dubbed into our language.



Categories: C Language

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: