0% found this document useful (0 votes)
22 views

Computer Languages

Uploaded by

souviks.phd18.ec
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Computer Languages

Uploaded by

souviks.phd18.ec
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Computer Languages

Dr Souvik Saha
Assistant Professor
Amity Institute of Information Technology
Amity University Kolkata
What is a Computer Language?
• Humans use languages like English, Bengali, Hindi, etc., to make communication
between two persons.
- When we want to make communication between two persons we need a
language through which persons can express their feelings.

• Similarly, when we want to make communication between user and computer or


between two or more computers we need a language through which user can give
information to the computer and vice versa.

• When a user wants to give any instruction to the computer the user needs a
specific language and that language is known as a computer language.
Classification of Computer Languages
Low Level Languages or First-Generation
Programming language
• Low-Level language is the only language which can be understood by the computer.
- Binary Language is an example of a low-level language.

• The binary language contains only two symbols 1 & 0.

• All the instructions of binary language are written in the form of binary numbers 1's &
0's.

• A computer can directly understand the binary language.

• Machine language is also known as the Machine Code.


Low Level Languages Continued…

• As the CPU directly understands the binary language instructions, it does not
require any translator.
• CPU directly starts executing the binary language instructions and takes very less
time to execute the instructions as it does not require any translation.
• Low-level language is considered as the First-Generation Language (1GL).
Low Level Languages Example
Advantages & Disadvantages of Machine Language

Advantages of Machine Language


• A computer can easily understand the low-level language.
• Low-level language instructions are executed directly without any translation.
• Low-level language instructions require very less time for their execution.

Disadvantages of Machine Learning Language


• Low-level language instructions are very difficult to use and understand.
• Low-level language instructions are machine-dependent, that means a program written for
a particular machine does not execute on another machine.
• In low-level language, there is more chance for errors, and it is very difficult to find
errors, debug and modify.
Middle Level Language (Second-generation
programming Language)

• Middle-level language is a computer language in which the instructions are created using
symbols such as letters, digits and special characters.
- Assembly language is an example of middle-level language.

• In assembly language, we use predefined words called mnemonics.

• Binary code instructions in low-level language are replaced with mnemonics and
operands in middle-level language.
Middle Level Language

• But the computer cannot understand mnemonics, so we use a translator


called Assembler to translate mnemonics into binary language.

• Assembler is a translator which takes assembly code as input and produces machine code
as output.

• The computer cannot understand middle-level language, so it needs to be translated into a


low-level language to make it understandable by the computer.

• Assembler is used to translate middle-level language into low-level language.


Middle Level Language Example
Advantages & Disadvantages of Middle Level
Language
Advantages
• Writing instructions in a middle-level language is easier than writing instructions in a
low-level language.
• Middle-level language is more readable compared to low-level language.
• Easy to understand, find errors and modify.

Disadvantages
• Middle-level language is specific to a particular machine architecture, that means it is
machine-dependent.
• Middle-level language needs to be translated into low-level language.
• Middle-level language executes slower compared to low-level language.
High Level Language (Third-generation programming
language)

• A high-level language is a computer language which can be understood by the users.

• The high-level language is very similar to human languages and has a set of grammar
rules that are used to make instructions more easily.

• Every high-level language has a set of predefined words known as Keywords and a set of
rules known as Syntax to create instructions.

• The high-level language is easier to understand for the users but the computer can not
understand it.
High Level Language (Continued…)

• High-level language needs to be converted into the low-level language to make it


understandable by the computer.

• We use Compiler or interpreter to convert high-level language to low-level language.

• Languages like COBOL, FORTRAN, BASIC, C, C++, JAVA, etc., are examples of
high-level languages.

• All these programming languages use human-understandable language like English to


write program instructions.

• These instructions are converted to low-level language by the compiler so that it can be
understood by the computer.
High Level Language (Continued…) Example
Advantages & Disadvantages of High-Level Language
Advantages
• Writing instructions in a high-level language is easier.
• A high-level language is more readable and understandable.
• The programs created using high-level language runs on different machines
with little change or no change.
• Easy to understand, create programs, find errors and modify.

Disadvantages
• High-level language needs to be translated into low-level language.
• High-level language executes slower compared to middle and low-level
languages.
Fourth - Generation Programming Language

• These are languages that consist of statements that are like statements in the human
language.
• These are used mainly in database programming and scripting.
• Examples of these languages include Perl, Python, Ruby, SQL, and MATLAB(Matrix
Laboratory).
• 4th generation language is also known as a domain-specific language or a high-
productivity language.
Features of Fourth - Generation Programming Language

• It reduces programming costs and time.


• It is a high-level programming language.
• Its program has greater usability.
• It accesses the database.
• Minimum efforts from the user to obtain any information.
Types of Fourth - Generation Programming Language

• Self-generator system.
• Report generator programming language.
• Form generators.
• Codeless programming.
• Data management.
Advantages and disadvantages of Fourth - Generation
Programming Language

• Advantages of 4GL:
• Smaller in size as compared to the previous generation’s language.
• Graphics User Interface (GUI) technology was introduced.
• Low maintenance cost.
• The heat generated was negligible.
• Portable and cheaper than the previous generation.
• Disadvantages of 4GL:
• Requires complex structure.
• The latest technology is required for the manufacturing of Microprocessors.
• Less flexible than other languages.
• Memory consumption is high.
Fifth - Generation Programming Language

• The fifth-generation languages are also called 5GL.


• It is based on the concept of artificial intelligence.
• It uses the concept that rather than solving a problem algorithmically, an application
can be built to solve it based on some constraints, i.e., we make computers learn to
solve any problem.
• Parallel Processing & superconductors are used for this type of language to make real
artificial intelligence.
• Examples: PROLOG, LISP, etc.
Advantages and disadvantages of Fifth - Generation
Programming Language

• Advantages of 5GL:
• Machines can make decisions.
• Programmer effort reduces to solve a problem.
• Easier than 3GL or 4GL to learn and use.
• Disadvantages of 5GL:
• Complex and long code.
• More resources are required & they are expensive too.
Language processors

• Computer programs are generally written in high-level languages (like C++, Python,
and Java).
• A language processor, or language translator, is a computer program that convert source
code from one programming language to another language or human readable language.
• They also find errors during translation.
• Language Processors: Compiler, Interpreter, Assembler
Compiler
• Compiler reads the complete source program written in high-level language in one
go and translates it into an equivalent program in machine language. Example: C,
C++, C#.
• In a compiler, the source code is translated to object code successfully if it is free
of errors.
• The compiler specifies the errors at the end of the compilation with line numbers
when there are any errors in the source code.
• The errors must be removed before the compiler can successfully recompile the
source code again.
Assembler
• The Assembler is used to translate the program written in Assembly language into
machine code.
• The source program is an input of an assembler that contains assembly language
instructions.
• The output generated by the assembler is the object code or machine code
understandable by the computer.
• Assembler is basically the 1st interface that can communicate humans with the machine.
• Code written in assembly language is some sort of mnemonics(instructions) like ADD,
MUL, SUB, DIV, MOV and so on.
• The assembler is basically able to convert these mnemonics in binary code. Here, these
mnemonics also depend upon the architecture of the machine.
• For example, the architecture of intel 8085 and intel 8086 are different.
Assembler (continued…)
Interpreter
• The translation of a single statement of the source program into machine code is
done by a language processor and executes immediately before moving on to the
next line is called an interpreter.
• If there is an error in the statement, the interpreter terminates its translating process
at that statement and displays an error message.
• The interpreter moves on to the next line for execution only after the removal of
the error.
• An Interpreter directly executes instructions written in a programming or scripting
language without previously converting them to an object code or machine code.
• An interpreter translates one line at a time and then executes it.
• Example: Perl, Python and MATLAB.
Interpreter (continued…)
Difference between compiler & interpreter
Compiler Interpreter

A compiler is a program that converts the entire An interpreter takes a source program and runs it
source code of a programming language into line by line, translating each line as it comes to it.
executable machine code for a CPU.

The compiler takes a large amount of time to An interpreter takes less amount of time to analyze
analyze the entire source code but the overall the source code but the overall execution time of
execution time of the program is comparatively the program is slower.
faster.

The compiler generates the error message only Its Debugging is easier as it continues
after scanning the whole program, so debugging translating the program until the error is met.
is comparatively hard as the error can be
present anywhere in the program.
Difference between compiler & interpreter
(continued…)
Compiler Interpreter
The compiler requires a lot of memory for It requires less memory than a compiler
generating object codes. because no object code is generated.

Generates intermediate object code. No intermediate object code is generated.

For Security purpose compiler is more useful. The interpreter is a little vulnerable in case of
security.
Examples: C, C++, C# Examples: Python, Perl, JavaScript, Ruby.
Linker
• 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
having .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.
Tasks of linker
• 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.
Loader
• 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.
• Loading Schemes
• 1. Absolute loaders
• 2. Relocating loaders
• 3. Direct linking loaders
• 4. Bootstrap loaders
Tasks of loader
• 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.
Linking & Loading
Difference between linker & loader
Linker Loader

The main function of Linker is to generate Main objective of Loader is to load


executable files. executable files to main memory.

The linker takes input of object code The loader takes input of executable files
generated by compiler/assembler. generated by linker.

Linking can be defined as process of Loading can be defined as process of


combining various pieces of codes and loading executable codes to main memory
source code to obtain executable code. for further execution.
Difference between linker & loader (Continued…)

Linker Loader

Linkers are of 2 types: Linkage Editor and Loaders are of 4 types: Absolute,
Dynamic Linker. Relocating, Direct Linking, Bootstrap.

Another use of linker is to combine all It helps in allocating the address to


object modules. executable codes/files.

Linker is also responsible for arranging Loader is also responsible for adjusting
objects in program’s address space. references which are used within the
program.

You might also like