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

Computer Language Unit 3

The document discusses different types of programming languages including low-level languages like machine code and assembly language, high-level languages, and fourth generation languages. It describes the key differences between low-level and high-level languages as well as compilers and interpreters.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Computer Language Unit 3

The document discusses different types of programming languages including low-level languages like machine code and assembly language, high-level languages, and fourth generation languages. It describes the key differences between low-level and high-level languages as well as compilers and interpreters.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

Computer Languages

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 low-level language is a programming language that provides no


abstraction from the hardware, and it is represented in 0 or 1 forms,
which are the machine instructions.
• The languages that come under this category are the
Machine level language and
Assembly language.
Machine-level language
• The machine-level language is a language that consists of a set of
instructions that are in the binary form 0 or 1. As we know that computers
can understand only machine instructions, which are in binary digits, i.e., 0
and 1, so the instructions given to the computer can be only in binary
codes.
• Creating a program in a machine-level language is a very difficult task as it is
not easy for the programmers to write the program in machine instructions.
• It is error-prone as it is not easy to understand, and its maintenance is also
very high.
• A machine-level language is not portable as each computer has its machine
instructions, so if we write a program in one computer will no longer be
valid in another computer.
Assembly Language
• The Assembly language contains some human-readable commands such as mov,
add, sub, etc. The problems which we were facing in machine-level language are
reduced to some extent by using assembly language. Since assembly language
instructions are written in English words like mov, add, sub, so it is easier to write
and understand.
• As we know that computers can only understand the machine-level instructions,
so we require a translator that converts the assembly code into machine code.
The translator used for translating the code is known as an Assembler.
• The assembly language code is not portable because the data is stored in
computer registers, and the computer has to know the different sets of registers.
• The assembly code is not faster than machine code because the assembly
language comes above the machine language in the hierarchy, so it means that
assembly language has some abstraction from the hardware while machine
language has zero abstraction.
Differences between Machine-Level language
and Assembly language
Machine-level language Assembly 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.

It cannot be easily understood by humans. It is easy to read, write, and maintain.

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 first-generation programming language. It is a second-generation programming language.


High-Level Language
• The high-level language is a programming language that allows a programmer to
write the programs which are independent of a particular type of computer. The
high-level languages are considered as high-level because they are closer to human
languages than machine-level languages.
• A Compiler is required to translate a high-level language into a low-level language.
• Advantages of a high-level language
The high-level language is easy to read, write, and maintain as it is written in
English like words.
The high-level languages are designed to overcome the limitation of low-level
language, which means the high-level language is portable and machine-
independent.
Differences between Low-Level language
and High-Level language
Low-level language High-level language

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.

It is memory efficient. It is less memory efficient.


Debugging and maintenance are not easier in a low-level Debugging and maintenance are easier in a high-level
language. language.
Fourth Generation Language
• A Fourth Generation (Programming) Language (4GL) is a grouping of programming
languages that attempt to get closer than 3GLs to human language, a form of thinking, and
conceptualization and are easier to use than 3GLs.
• It is a non-procedural language which means that the programmer defines what has to be
done instead of how the task is to be completed.
• 4GL is more familiar and similar to human language.
• A compiler translates the whole program once i.e. it generates the object code for the
program along with the list of errors.
• The execution is very fast.
• These languages are usually designed for specific purposes and are commonly used in
database programming and scripts such as PHP, Python, SQL, and many more.
• 4GLs make programming easier, more efficient, and more effective for users with less
programming skills.
• 4th generation language is also known as a domain-specific language or a high-productivity
Components of Fourth Generation:
• Databases and tables: The Database and the tables on which the 4GL
programs operate.
• Form or Module: The screen that is displayed for the user data entry.
The source code for forms is saved in files such as forms. For a form
available to a 4GL program, it must be compiled into a file with a .frm
suffix.
• Main Function: Each executable program has the MAIN function; it is the
first thing that is executed and in turn calls other functions.
• Function: Portions of 4GL programs that can be called from MAIN and
other functions. These start with the FUNCTION keyword.
• Reports: Portions of 4GL programs that create reports.
• Programs: This is what is actually executed by the users.
Fourth Generation 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.
Less flexible than other languages.
Memory consumption is high.
Compiler
• The Compiler is a translator which takes input i.e., High-Level
Language, and produces an output of low-level language i.e. machine
or assembly language. The work of a Compiler is to transform the
codes written in the programming language into machine code
(format of 0s and 1s) so that computers can understand.
• 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
memory.
• It has a slow speed because a compiler goes through the entire
program and then translates the entire program into machine codes.
Compiler
Compiler
• Advantages of Compiler
Compiled code runs faster in comparison to Interpreted code.
Compilers help in improving the security of Applications.
Compilers give Debugging tools so fixing the errors is easy.
• Disadvantages of Compiler
Only syntax errors and some semantic errors can be detected.
Compilation can take more time in the case of bulky code.
Interpreter
• An Interpreter is a program that translates a programming language
into an intermediate language. It contains pre-compiled code, source
code, etc.
• It translates only one statement of the program at a time.
• Interpreters are, in general, smaller than compilers.
Interpreter
• Advantages of Interpreter
Programs written in an Interpreted language are easier to debug.
Interpreters allow the management of memory automatically,
which reduces memory error risks.
Interpreted Language is more flexible than a Compiled language.
• Disadvantages of Interpreter
The interpreter can run only the corresponding Interpreted
program.
Interpreted code runs slower in comparison to Compiled code.
Difference Between Compiler and Interpreter
Compiler Interpreter
The compiler saves the Machine Language in form of The Interpreter does not save the Machine Language.
Machine Code on disks.
Compiled codes run faster than Interpreter. Interpreted codes run slower than Compiler.
Linking-Loading Model is the basic working model of The Interpretation Model is the basic working model
the Compiler. of the Interpreter.
The compiler generates an output in the form of The interpreter does not generate any output.
(.exe).
Any change in the source program after the Any change in the source program during the
compilation requires recompiling the entire code. translation does not require retranslation of the entire
code.

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.)

• Locality: A good programming language should be such that while writing a


program, a programmer need not jump around visually while writing the
program. It allows the programmer to concentrate on the part of the
program around the statement they are currently working on.
• Extensibility: A good programming language should allow extension through
simple, natural, and elegant mechanisms. Almost all languages provide
subprogram definition mechanisms for this purpose, but some are weak.
• Suitability to its environment: In addition to being suitable for its
application area, a good programming language must also be ideal for its
operating environment. For example, a language for real-time applications
must be interactive. On the other hand, a language for data processing
applications like payroll, stores accounting, etc., may operate in batch mode.

You might also like