Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 23

Objectives

• show understanding of the need for both high-level


and low-level languages
• show understanding of the need for compilers when
translating programs written in a high-level language
• show understanding of the use of interpreters with
high-level language programs
• show understanding of the need for assemblers when
translating programs written in assembly language
1.3.7 High- and low-level languages and their translators

Human Languages
• Bonjour
• Comment allez vous?
• Tu vas bien?
• Bien sûr, vous êtes bon

Hello
How are you?
You're okay?
of course you are good
1.3.7 High- and low-level languages and their translators

Computer Program
• Human languages are known as natural
languages. Unfortunately, computers can
not understand natural languages, as a
result we must communicate with
computers using computer languages.
• These languages are;
• High Level Languages

• Low Level Languages


• Assembly Language

• Machine Language
1.3.7 High- and low-level languages and their translators

Parity bits
1.3.7 High- and low-level languages and their translators

High Level Language


• The high-level languages are much closer to human
language.
• A programming language such as C, FORTRAN or
Pascal that enables to write programs which is
understandable to programmer (Human) and can
perform any sort of task, such languages are
considered high-level because they are closer to
human languages.
• High level language must use interpreter, compiler
or translator to convert human understandable
program to computer readable code (machine
code).
1.3.7 High- and low-level languages and their translators

High Level - Examples


• Many high level languages have appeared since
invention of computer the most widely used have
been:
• COBOL Business applications
• FORTRAN Engg & Scientific Applications
• PASCAL General use and as a teaching tool
• C & C++ General Purpose - currently most popular.
• PROLOG Artificial Intelligence
• JAVA General all purpose programming
• .NET General or web applications.
1.3.7 High- and low-level languages and their translators

High Level - Examples


1.3.7 High- and low-level languages and their translators

Characteristics of High Level Language


• easier/faster to write code as uses English-like statements
• easier/faster to modify as uses English-like statements
• easier/faster to debug as uses English-like statements
• portable language code
• fewer instructions
• no need to understand registers/computer architecture
• instructions nearer to human language/English
• not machine /operating systems specific/portable
• one statement is equal to many low-level language statements
1.3.7 High- and low-level languages and their translators

Advantages of HLL
• one statement is equal to many low-level language
statements
• problem oriented
• needs converting to machine code before execution
1.3.7 High- and low-level languages and their translators

Low Level Languages


Low-level languages relate to the specific architecture
and hardware of a particular type of computer. Low-level
languages can refer to machine code, the binary
instructions that a computer understands, or an
assembly language that needs to be translated into
machine code.
1.3.7 High- and low-level languages and their translators

Characteristics of Low- Level Language


– can work directly on memory locations
– can be executed faster
– translated program requires less memory

– direct access to computer processor / special


hardware // machine dependent instructions
– uses up less memory
– can increase the speed of processing a program //
executes instructions faster
1.3.7 High- and low-level languages and their translators

Advantages of Low- Level Language


− work directly on registers/CPU
− more control over what happens in computer
− can use machine specific functions
1.3.7 High- and low-level languages and their translators

Assembly languages
Programmers write code in assembly language for
following reasons:
• to make use of special hardware
• to make use of special machine-dependent
instructions
• to write code that doesn’t take up much space in
primary memory to write code that performs a task
very quickly.
1.3.7 High- and low-level languages and their translators

Machine code
• Programmers do not usually write in machine code
as it is difficult to understand and it can be
complicated to manage data manipulation and
storage.
• The following snippet of program to add two numbers
together

• As you can see, this is not easy to understand in


binary! Machine code is usually shown in
hexadecimal
1.3.7 High- and low-level languages and their translators

Language Translators
• Language Translators convert programming source
code into language that the computer processor
understand.
• Programming source code has various structures
and commands, but the computer processors
understand only machine language.
• Language translators are of three types:
• Compiler
• Interpreter
• Assembler
1.3.7 High- and low-level languages and their translators

Compiler
• Translates the whole HLL program as a
complete unit / at once.
• Creates an executable file / object code.
• A report / list of errors in the code is created.
• Optimises the source code (to run efficiently)
1.3.7 High- and low-level languages and their translators

Interpreter
• Translates a HLL program one line of code at a
time.
• Machine code is directly executed // The
interpreter is used each time.
• the program / code is executed.
• Will identify an error as soon as it finds one in
a line of code.
1.3.7 High- and low-level languages and their translators

Assembler
• translates a program written in an assembly
language into machine code so that it can be directly
used by a computer to perform a required task.
Once a program is assembled the machine code can
be used again and again to perform the same task
without re-assembly.
1.3.7 High- and low-level languages and their translators

Summary of Translation Programs


1.3.7 High- and low-level languages and their translators

Interpreter Vs Compiler
Statements Interpreter Compiler

Translates the source code into Yes


machine code all at once
Produces an executable file in Yes
machine code
Executes a high-level language Yes
program one
instruction at a time
Once translated, the translator Yes
does not need to be present for
the program to run
An executable file is produced Yes
1.3.7 High- and low-level languages and their translators

Error in Program
Error
Syntax Error – Where a program statement doesn’t
obey the rules of the programing language. A program
cannot be translated if it contains syntax errors.
Compiler : A list of all errors in whole program.
Interpreter : Check program statements until found any
error; after rectification of error, program will
reinterpreted & may stop at next error.

Logic Error – Is Where the program doesn’t do that the


programmer wanted it to do. Logic Error are found when a
program is being run. These can be found by tracing what
the program does and using test data with expected result.
1.3.7 High- and low-level languages and their translators

Summary
• High-level language
• Low-level language
• Machine code
• Assembly language
• Syntax
• Compiler
• Interpreter
• Source code
• Executable file
1.3.7 High- and low-level languages and their translators

Summary
• Mnemonic codes
• Assembler
• Driver

You might also like