Categories: IT Officer

Compiler, Assembler and Interpreter

Compiler, Assembler and Interpreter

It is difficult to write and maintain programs in machine level language. The programs written in the code of high level language and low level language need to be converted into machine level language using translators for this purpose. Translators are just computer programs which accept a program written in high level or low level language and produce an equivalent machine level program as output. Translators are of three types:

COMPILER: It is a program which translates a high level language program into a machine language program. A compiler is more intelligent than an assembler. It checks all kinds of limits, ranges, errors etc. But its program run time is more and occupies a larger part of the memory. It has slow speed. Because a compiler goes through the entire program and then translates the entire program into machine codes. If a compiler runs on a computer and produces the machine codes for the same computer then it is known as a self-compiler or resident compiler. On the other hand, if a compiler runs on a computer and produces the machine codes for other computer then it is known as a cross compiler.

Advantages:

  • Source code is not included, therefore compiled code is more secure than interpreted code
  • Tends to produce faster code than interpreting source code
  • Produces an executable file, and therefore the program can be run without need of the source code

Disadvantages:

  • Object code needs to be produced before a final executable file, this can be a slow process
  • The source code must be 100% correct for the executable file to be produced

Example: GCC, Microsoft Visual Studio

INTERPRETER: An interpreter is a program which translates statements of a program into machine code. It translates only one statement of the program at a time. It reads only one statement of program, translates it and executes it. Then it reads the next statement of the program again translates it and executes it. In this way it proceeds further till all the statements are translated and executed.

Advantages:

  • Easier to debug(check errors) than a compiler
  • Easier to create multi-platform code, as each different platform would have an interpreter to run the same code
  • Useful for prototyping software and testing basic program logic

Disadvantages:

  • Source code is required for the program to be executed, and this source code can be read making it insecure
  • Interpreters are generally slower than compiled programs due to the per-line translation method

Example: Python, LISP, Ocamle

ASSEMBLER: A computer will not understand any program written in a language, other than its machine language. The programs written in other languages must be translated into the machine language. Such translation is performed with the help of software. A program which translates an assembly language program into a machine language program is called an assembler. If an assembler which runs on a computer and produces the machine codes for the same computer then it is called self-assembler or resident assembler. If an assembler that runs on a computer and produces the machine codes for other computer then it is called Cross Assembler.

Advantages:

  • Very fast in translating assembly language to machine code as 1 to 1 relationship
  • Assembly code is often very efficient (and therefore fast) because it is a low level language
  • Assembly code is fairly easy to understand due to the use of English-like mnemonics

 

Disadvantages:

  • Assembly language is written for a certain instruction set and/or processor
  • Assembly tends to be optimized for the hardware it’s designed for, meaning it is often incompatible with different hardware
  • Lots of assembly code is needed to do relatively simple tasks, and complex programs require lots of programming time.

             Example: MASM, NASM.

Preeti Singh

Disqus Comments Loading...

Recent Posts

Current Affairs For 19th & 20th November 2023

Hola! If you haven't heard this quote yet, take a moment to read it here.…

6 months ago

Current Affairs For 18th November 2023

"Think good an good follows. Think evil and evil follows. Think creative and creativity will…

6 months ago

Current Affairs For 17th November 2023

Better late than never! Apologies for the delay in responding, but I'm here now to…

6 months ago

Current Affairs For 27th October 2023

By providing accurate information, context, promoting critical thinking, raising awareness, connecting global and local issues,…

6 months ago

Current Affairs For 25th & 26th October 2023

Current affairs coverage often showcases stories of individuals and communities making a positive impact. Q1.…

6 months ago

Current Affairs For 24th October 2023

Current affairs coverage helps individuals understand the interconnectedness of global and local events. It shows…

6 months ago