Computer Language Unit 3
Computer Language Unit 3
By
Rimple Dhamija,
IMT, FBD
Programming Language
• A programming language defines a set of instructions that are
compiled together to perform a specific task by the CPU (Central
Processing Unit). Example C, C++, Pascal, Ada, COBOL, etc.
• Each programming language contains a unique set of keywords and
syntax, which are used to create a set of instructions.
• Each language has its specific purpose.
• Two categories:
Low-level language
High-level language
Programming Language
Low-level language
The machine-level language comes at the lowest level in The assembly language comes above the machine
the hierarchy, so it has zero abstraction level from the language means that it has less abstraction level from the
hardware. hardware.
The machine-level language is written in binary digits, i.e., The assembly language is written in simple English
0 and 1. language, so it is easily understandable by the users.
It does not require any translator as the machine code is In assembly language, the assembler is used to convert
directly executed by the computer. the assembly code into machine code.
It is a machine-friendly language, i.e., the computer It is a user-friendly language as this language is written in
understands the machine language, which is represented simple English words, which can be easily understood by
in 0 or 1. humans.
The low-level language takes more time to execute. It executes at a faster pace.
It requires the assembler to convert the assembly code It requires the compiler to convert the high-level language
into machine code. instructions into machine code.
The machine code cannot run on all machines, so it is not The high-level code can run all the platforms, so it is a
a portable language. portable language.
Errors are displayed in Compiler after Compiling Errors are displayed in every single line.
together at the current time.
The compiler can see code upfront which helps in The Interpreter works by line working of Code, that’s
running the code faster because of performing why Optimization is a little slower compared to
Optimization. Compilers.
Difference Between Compiler and Interpreter
Compiler Interpreter
Execution of the program takes place only after the Execution of the program happens after every line is
whole program is compiled. checked or evaluated.
Compilers more often take a large amount of time for Interpreters take less time for analyzing the source
analyzing the source code. code.
CPU utilization is more in the case of a Compiler. CPU utilization is less in the case of a Interpreter.
Object code is permanently saved for future use. No object code is saved for future use.
C,C++, C#, etc are programming languages that are Python, Perl, MATLAB, etc are programming languages
compiler-based. that are interpreter-based.
Assembler
• An assembly language which is basically mnemonics like GO, HALT,
JUMP, and NOT code which is translated to the machine language by
programming language translator i.e., Assembler.
• Assembler is a program that takes assembly language as source code
and converts it into the bit format i.e machine language which is
understandable by the computers. For example NASM and MASM.
Assembler
• Assembler is a program for converting instructions written in low-level assembly code
into machine code.
• It is necessary to convert Programming language code into a machine code. This is
called as translation of the high level language to low level. This type of translation is
performed with the help of system software.
• Assembler can be defined as a program that translates an assembly language program
into a machine language program.
Self assembler is a program that runs on a computer and produces the
machine codes for the same computer or same machine.
Cross assembler is an assembler which runs on a computer and produces the
machine codes for other computer.
• It generates instructions by evaluating the mnemonics (symbols) in operation field and
find the value of symbol and literals to produce machine code.
If assembler do all this work in one scan then it is called single pass assembler,
If it does in multiple scans then called multiple pass assembler.
Difference between Assembler and
Interpreter :
Assembler Interpreter
It converts low-level language to the machine It converts high-level language to the machine
language. language.
The program for an Assembler is written for particular The program for an Interpreter is written for particular
hardware. language.
It is one to one i.e. one instruction translates to only It is one to many i.e. one instruction translates to
one instruction. many instruction.
It translates entire program before running. It translates program instructions line by line.
Errors are displayed before program is running. Errors are displayed for the every interpreted
instruction (if any).
It is used only one time to create an executable file. It is used every time when the program is running.
Requirement of memory is less. Requirement of memory is more.
Programming language that it convert is Assembly Programming language that it convert are PHP,
language. Python, Perl, Ruby.
Linker
• A linker is special program that combines the object files, generated
by compiler/assembler and other pieces of code to originate an
executable file which has .exe extension.
• In the object file, linker searches and append all libraries needed for
execution of file.
• It regulates the memory space that will hold the code from each
module.
• It also merges two or more separate object programs and establishes
link among them.
• Generally, linkers are of two types :
1. Linkage Editor
2. Dynamic Linker
Linker
• The linker performs several tasks, including:
Symbol resolution: The linker resolves symbols in the program
that are defined in one module and referenced in another.
Code optimization: The linker optimizes the code generated by
the compiler to reduce code size and improve program performance.
Memory management: The linker assigns memory addresses to
the code and data sections of the program and resolves any
conflicts that arise.
Library management: The linker can link external libraries into
the executable file to provide additional functionality.
Linker
Loader
• It is special program that takes input of executable files from linker, loads it to
main memory, and prepares this code for execution by computer.
• Loader allocates memory space to program.
• Also, it creates symbolic reference between objects.
• It loads programs and libraries in operating system.
• The loader performs several tasks, including:
Loading: The loader loads the executable file into memory and allocates
memory for the program.
Relocation: The loader adjusts the program’s memory addresses to reflect its
location in memory.
Symbol resolution: The loader resolves any unresolved external symbols that
are required by the program.
Dynamic linking: The loader can dynamically link libraries into the program at
runtime to provide additional functionality.
Differences between Linker and Loader are
as follows:
LINKER LOADER
The main function of Linker is to generate executable Main function of Loader is to load executable files to
files. main memory.
The linker takes input of object code generated by Loader takes input of executable files generated by
compiler/assembler. linker.
Linking can be defined as process of combining various Loading can be defined as process of loading
pieces of codes and source code to obtain executable executable codes to main memory for further
code. execution.
Characteristics of a Good Programming
Language
• Simplicity: A good programming language must be simple and easy to learn and use.
It should provide a clear and simple concepts to a programmer that they can grasp
quickly. Programs should be easier to read and understand and easier to maintain.
• Naturalness: A good language for an application area should be natural for
programming applications. It should provide appropriate operators, data structures,
control structures, and a natural syntax to facilitate programmers to code their
problems quickly and efficiently. FORTRAN and COBOL are good examples of
languages possessing a high degree of naturalness in scientific and business
application areas, respectively.
• Abstraction: Abstraction means the ability to define and then use complicated
structures or operations in ways that allow programmers to ignore many of the
details. The degree of abstraction a programming language allows directly affects its
ease of programming. For example, object-oriented languages support a high degree
of abstraction. Hence, writing programs in object-oriented programming (OOP)
languages is much easier.
Characteristics of a Good Programming
Language (contd.)
• Efficiency: A program written in a suitable programming language
enables a computer system to translate it into machine code
efficiently, execute it efficiently, and manage it with less memory. A
good programming language is supported by a good language
translator (a compiler or an interpreter) that considers space and time
efficiency.
• Structured programming Support: A good programming language
should have the necessary features to allow programmers to write
their programs based on structured programming concepts.
• Compactness: In a good programming language, programmers should
be able to express the intended operations concisely without losing
readability.
Characteristics of a Good Programming
Language (contd.)