Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

SUBMITTED TO:

SIR NAUMAN SHAMIM

Assignment submitted by : Malaika Haider

SERIAL NO# 31
Department : Chemistry

1/8/2024
Compiler, Interpreter, their role, working, pros
and cons and difference. Provide name of at
least two programing languages from each
category.
COMPILER:
A compiler translates the entire source code of
a program into machine code or an
intermediate code in a single batch.it checks
the entire code for syntax errors before
generating the executable file.
Working:
The compilation process involves multiple
stages. It includes lexical analysis, syntax
analysis, semantic analysis, optimization and
code generation. The resulting executable file
can be run independently of the original source
code.
PROS:
 Efficiency:
Compiled code tends to be more
efficient as it is optimized during the
compilation process.
 Performance:
Once compiled the program runs faster
as compared to interpreted code.
CONS:
 Debugging:
Debugging can be more challenging
sine the entire program is translated before
execution.
 Portability:
Compiled programs are often
platform-specific.
Examples:
C and C++, JAVA
Interpreter:
An interpreter translates and executes the
source code line by line, without producing an
intermediate machine code file.it checks each
line before going to next.
Working:
The interpreter translates the source code into
the machine code or an intermediate code one
line at a time and executes it immediately.
Errors are reported as soon as they are
encountered.
PROS:
 DEBUGGING: Easier to debug since errors
are reported immediately.
 Portability: Programs can be run on any
platform with the corresponding
interpreter.
CONS:
 Performance: Generally slower compared
to compiled code as the translation
happens at runtime.
 Efficiency: may lack the optimization
achieved by compilers.
Examples:
Python and JavaScript
Difference between Compiler and Interpreter:
 Compiler translates the entire source
code into machine code before execution
while interpreter translates and executes
the source code line by line.
 Compiler produces a standalone
executable file while interpreter requires
the interpreter on the system to execute
the code.
 Compiler debugging can be more
challenging while interpreter is easy to
debug since errors are reported
immediately.
 Compiler produces faster-running code
while interpreter may be slower as
translation happens at runtime.
Write about at least three programming
languages that are presently trending, write
their main features, write only brief
description.
1. Python:
 High-level, interpreted language.
 Emphasizes readability and
simplicity, making it an excellent
choice for beginners.
 Versatile and widely used in various
domains, including web
development, data science, artificial
intelligence and automation.
2. JavaScript:
 Scripting language primarily used for
front-end web development.
 Runs in web browsers, allowing
dynamic and interactive user
interfaces.
 Support asynchronous
programming, making it suitable for
building responsive web
applications.
3. TypeScript:
 Superset of JavaScript with static
typing.
 Adds static typing to JavaScript,
which helps catch errors during
development.
 Widely adopted for large-scale web
applications, especially those build
using the angular framework.
What is CPU? How does it work, what are its
different components?
CPU (CENTRAL PROCESSING UNIT):
CPU is also called “brain” of a computer. It is
responsible for performing functions requires
for the operation of the computer system.
Working:
CPU works in conjunction with the other
components of the computer to carry out
instructions from software programs. The basic
operation of a CPU involves fetching, decoding,
executing and storing instructions.
1. Fetch:
The CPU fetches instructions from
the computer’s memory or cache.
2. Decode:
The fetches instructions are
decoded into signals that the CPU can
understand.
3. Execute:
The CPU performs the actual
operations
4. Store:
The results of the executed
instructions may be stored in memory or
registers for future use.
Components:
1. Control unit (CU):
It is responsible for controlling and
coordinating the operations of the CPU.
2. ARITHMETIC LOGIC UNIT(ALU):
it is responsible for executing
mathematical and logical instructions.
3. REGISTERS:
It is small, high speed storage locations
which is used to store data temporarily
during processing.
4. CACHE MEMORY:
High speed volatile computer memory
that provides high speed data access to
the CPU.
5. CLOCK:
it generates the clock pulses that
synchronize the operations of the CPU.
6. BUS SYSTEM:
The system of buses that facilitates
communication between the CPU,
memory and other peripheral devices.
What is RAM or memory, what are its
different types and how programs are loaded
into memory?
RAM (Random Access Memory):
RAM is a type of computer memory that is use
for the temporary storage of data that is
actively being used or processed by a
computer. RAM provides quick and temporary
access to data for the CPU, allowing for faster
data manipulation and execution of programs.
TYPES:
1. DRAM (DYNAMIC RAM)
2. SRAM (STATIC RAM)
3. DDDR (double data rate synchronous
dynamic RAM)
4. VRAM (video RAM)
Loading of programs in the memory:
When a program is executed, it needs to be
loaded into the computer’s memory so that the
CPU can access its instructions and data.
It includes the following steps.
1. Loading:
the operating system loads the program
into the memory from storage devices
when the program is launched.
2. Addressing:
each location in the memory is
assigning a unique address. The program’s
instructions and data loaded into specific
memory addresses.
3. Execution:
the CPU fetches instructions from
the memory using the program counter and
executes them.
4. Dynamic loading:
in some cases, not all parts of a
program need to be loaded into memory
initially.it allows portions of a program to
be loaded into memory as they are needed
during execution.
5. Dynamic linking:
external libraries or modules can be
linked to a program during its execution,
allowing for more modular and efficient use
of memory.
6. Memory management:
the operation system manages memory
allocation and deallocation to ensure
efficient use of available resources.
Virtual memory system may be used to
extend available RAM by using part of the
hard drive as additional memory.

RAM is the critical component for the


computers performance as it provides fast
and temporary storage for actively used
data and programs.

You might also like