UPSC Exam  >  UPSC Notes  >  Famous Books for UPSC Exam (Summary & Tests)  >  Program Compiler and Program Interpreter - Computer Software, Computer Awareness

Program Compiler and Program Interpreter - Computer Software, Computer Awareness | Famous Books for UPSC Exam (Summary & Tests) PDF Download

Introduction 

When we write a program using languages like C or Python, the computer cannot understand it directly. It needs to be changed into a language that the computer understands, which is machine language. This task is done using two tools: a compiler and an interpreter. In this document, we will learn what these tools do and how they are different from each other.

Program Compilation

  • A compiler is a program that converts source code written in high-level programming languages like C, C++, or Java into machine code.
  • Machine code is a low-level language that the computer's processor can understand and execute directly.
  • The process of converting source code into machine code is called compilation.
  • A compiler reads the entire program at once and translates it into an executable file.
  • The executable file can run on its own without needing the original source code or compiler again.
  • Compilers also check the code for syntax errors before converting it.
  • They optimize the code to make it run more efficiently and use less memory.
  • The compilation process may include steps like preprocessing, compiling, assembling, and linking.
  • The final output is usually a binary file such as a .exe file on Windows.
  • Compiled programs run faster and are commonly used for building large software applications.
  • If any changes are made to the source code, the entire program needs to be compiled again.

Question for Program Compiler and Program Interpreter - Computer Software, Computer Awareness
Try yourself:
What must happen to source code before a computer can execute it?
View Solution

Program Interpreter

  • An interpreter is a program that reads and executes code. This includes source code, pre-compiled code, and scripts. Common interpreters include Perl, Python, and Ruby interpreters, which execute Perl, Python, and Ruby code respectively.
  • Interpreters and compilers are similar, since they both recognize and process source code. However, a compiler does not execute the code like an interpreter does. Instead, a compiler simply converts the source code into machine code, which can be run directly by the operating system as an executable program. Interpreters bypass the compilation process and execute the code directly.
  • Since interpreters read and execute code in a single step, they are useful for running scripts and other small programs. Therefore, interpreters are commonly installed on Web servers, which allows developers to run executable scripts within their webpages. These scripts can be easily edited and saved without the need to recompile the code.
  • While interpreters offer several advantages for running small programs, interpreted languages also have some limitations.
  • The most notable is the fact that interpreted code requires an interpreter to run. Therefore, without an interpreter, the source code serves as a plain text file rather than an executable program.
  • Additionally, programs written for an interpreter may not be able to use built-in system functions or access hardware resources like compiled programs can. Therefore, most software applications are compiled rather than interpreted.

Program Compiler and Program Interpreter - Computer Software, Computer Awareness | Famous Books for UPSC Exam (Summary & Tests)

Difference between Interpreter and Compiler

Program Compiler and Program Interpreter - Computer Software, Computer Awareness | Famous Books for UPSC Exam (Summary & Tests)

The document Program Compiler and Program Interpreter - Computer Software, Computer Awareness | Famous Books for UPSC Exam (Summary & Tests) is a part of the UPSC Course Famous Books for UPSC Exam (Summary & Tests).
All you need of UPSC at this link: UPSC
1179 videos|2219 docs|849 tests

FAQs on Program Compiler and Program Interpreter - Computer Software, Computer Awareness - Famous Books for UPSC Exam (Summary & Tests)

1. What is a program compiler?
Ans. A program compiler is a computer software that translates the source code of a program written in a high-level programming language into machine code or a lower-level language that can be directly executed by the computer's hardware. It performs a series of complex processes such as lexical analysis, syntax analysis, semantic analysis, and code generation to convert the code into a form that can be understood and executed by the computer.
2. What is a program interpreter?
Ans. A program interpreter is a software that directly executes the source code of a program written in a high-level programming language without explicitly converting it into machine code. Instead of translating the entire code before execution, an interpreter reads and executes the code line by line or statement by statement. It analyzes and executes each instruction in real-time, which makes it slower compared to a compiler but provides greater flexibility and ease of debugging.
3. What are the advantages of using a program compiler?
Ans. There are several advantages of using a program compiler: - Compiled programs generally execute faster as the code is translated into machine code beforehand. - Once compiled, the program can be executed multiple times without the need for recompilation, which saves time. - Compilers perform optimization techniques to improve the efficiency of the code. - Compiled programs are less dependent on the presence of the compiler, making them more portable. - Compilation helps in detecting errors and bugs in the code early on, enabling developers to fix them before execution.
4. What are the advantages of using a program interpreter?
Ans. Some advantages of using a program interpreter include: - Interpreted programs are platform-independent as they are executed by the interpreter, which abstracts the underlying hardware. - Interpreters provide a dynamic execution environment where code can be modified and executed interactively. - Debugging is easier with an interpreter as it allows developers to execute code step-by-step and analyze the intermediate results. - Interpreted programs are more flexible and can be easily modified without the need for recompilation. - Interpreters are useful for scripting languages, where rapid development and ease of use are prioritized over execution speed.
5. Can a program be both compiled and interpreted?
Ans. Yes, a program can be both compiled and interpreted. This is known as hybrid or just-in-time (JIT) compilation. In this approach, the program is initially compiled into an intermediate representation, which is then interpreted by an interpreter or a runtime system. The interpreter executes the intermediate code and can also dynamically compile certain parts of the code into machine code for better performance. This combination allows for a balance between execution speed and flexibility, as well as the ability to optimize code during runtime.
Related Searches

mock tests for examination

,

Previous Year Questions with Solutions

,

Computer Awareness | Famous Books for UPSC Exam (Summary & Tests)

,

Program Compiler and Program Interpreter - Computer Software

,

shortcuts and tricks

,

Summary

,

Objective type Questions

,

Sample Paper

,

study material

,

Viva Questions

,

Computer Awareness | Famous Books for UPSC Exam (Summary & Tests)

,

Exam

,

ppt

,

Free

,

Program Compiler and Program Interpreter - Computer Software

,

Extra Questions

,

Computer Awareness | Famous Books for UPSC Exam (Summary & Tests)

,

video lectures

,

past year papers

,

MCQs

,

pdf

,

practice quizzes

,

Important questions

,

Program Compiler and Program Interpreter - Computer Software

,

Semester Notes

;