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

2 High Level and Translators

C-Programming
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

2 High Level and Translators

C-Programming
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

HIGH LEVEL LANGUAGES

High level language source programs are written in statements closer to


human language such as English.

A high level language code is executed by translating it into the


corresponding machine language code with the help of a compiler or
interpreter.

High languages are machine independent. They can be transferred from


one computer to another.

1
Characteristics of high languages include:

o It reflects the type of problem solved rather than the features of the
machine.

o It is machine independent.

o Easy to write and understand.

o High level language is portable across different machine types


(architectures);

o They contain statements that have an extensive vocabulary of words,


symbols, sentences &mathematical expressions, which are very similar to
the normal English language

o They require one to be obey a set of rules when writing the program.
2
High level languages can be classified
into the following categories;
o Procedural/ structured languages (third generation language)

o Problem-oriented/Fourth generation languages

o Object-Oriented languages.

o Event-driven Programming languages.

o Internet Programming Languages

o Mobile application Programming Languages

o Natural languages
3
PROCEDURAL/ STRUCTURED LANGUAGES
(THIRD GENERATION LANGUAGE)
o They are designed to express the logic and procedure of a problem.

o It allows a large program to be broken into smaller subprograms called


modules, each performing a particular (single) task.

o This technique of program design is also referred to as structured


programming.

o Though the syntax of the languages may be different, they use English-like
commands that are easy to follow. Examples include BASIC, COBOL,
FORTRAN, C and Pascal.
4
Problem-Oriented/Fourth Generation
Languages
o Are used to solve specific problems and includes query languages, report
generators and Application generators which have simple English like
syntax rules.
o A single statement of the 4GL can perform the same task as multiple line
of a third-generation language.
o They concentrate on what you want to do rather than how you are going
to do it.
o They present the programmer with more programming tools, such as
command buttons, forms, textboxes etc.
o The programmer simply selects graphical objects called controls on the
screen, and then uses them to create designs on a form by dragging a
mouse pointer.
o 4GL languages include SQL, Dbase 3+ and FoxPro.
5
OBJECT-ORIENTED LANGUAGES
o The major objective of object-oriented approach is extending the capabilities of
procedure language by including data element in program design.

o OOP ties data more closely to the functions that operate on it and protects it
from accidental modification from other functions.

o OOP allows decomposition of a problem into a number of entities called objects


and then builds data and functions around these objects.

o OOP languages include C++, C#, Object Delphi Pascal, Java among others.

6
EVENT-DRIVEN PROGRAMMING
LANGUAGES
o It is a programming paradigm in which the flow of the program is
determined by events such as user actions (mouse clicks,
movements, key presses).

o It is popularly used in Graphical User Interface (GUI) systems and


web applications.

o Examples include Visual Basic, Visual Delphi, and Java etc.

7
INTERNET PROGRAMMING
LANGUAGES
o Languages used to design websites and manipulate data entered
via a web form.

o There are two types of internet programming languages that is:


 Server-side languages e.g. PHP, Perl and
 Client-side languages e.g. JavaScript, XHTML.

8
MOBILE APPLICATION
PROGRAMMING LANGUAGES
o Used to develop application software for handheld devices as
personal digital assistant and mobile phones.

o These applications can be pre-installed on phone during


manufacturing or downloaded by customers e.g. action script,
Java, Python, Kotlin, Swift, Android etc.

9
NATURAL LANGUAGES (FIFTH
GENERATION)
o They are designed to make a computer to behave like an expert and
solve problems.

o The languages are able to make a computer solve a problem for the
programmer; hence, he/she does not spend a lot of time in coming up
with the solution.

o The programmer only thinks about what problem needs to be solved


and what conditions need to be met without worrying about how to
implement an algorithm to solve the problem.

o They’re mostly used in artificial intelligence and expert systems. 10


ADVANTAGES OF HIGH-LEVEL
LANGUAGES
o They are easily portable, i.e., they can be transferred between
computers of different families and run with little or no modification.

o High-level language programs are short, and take shorter time to be


translated.

o They are easy to lean, understand and use.

o They are easy to debug (correct/remove errors), & maintain.

o High level language programs are easy to modify, and also to


incorporate additional featuresthus enhancing its functional capabilities.

o They are ‘user-friendly’ & problem-oriented; hence, can be used to solve


11
DISADVANTAGES OF USING HIGH-
LEVEL LANGUAGES
o High-level languages are not machine-oriented; hence, they do not
use of the CPU and hardware facilities efficiently.

o The languages are machine-independent, and cannot be used in


programming the hardware directly.

o Each high-level language statement converts into several machine


code instructions. This means that, they use more storage space,
and it also takes more time to run the program.

12
LANGUAGE TRANSLATORS

o A computer uses & stores information in binary form, and therefore, it


cannot understand programs written in either high-level or low-level
languages.

o This means that, any program code written in Assembly language or


high-level language must be translated into Machine language, before
the computer can recognize & run these programs.

o A Translator is special system software used to convert the Source codes


(program statements written in any of the computer programming
13
languages) to their Object codes (computer language equivalents).
Translators Cont’d…
o Translators check for & identify some types of errors (e.g.,
Syntax/grammatical errors) that may be present in the program being
translated. They will produce error messages if there is a mistake in the
code.

o Each language needs its own translator. Generally, there are 3 types of
language translators:
1. Assembler

2. Interpreter

3. Compiler.
14
ASSEMBLER

An assembler translates programs written in Assembly language into machine


language that the computer can understand and execute.

Functions:

1.It checks whether the instructions written are valid, and identifies any errors in
the program.

2.It assigns memory locations to the names the programmer uses. E.g., the
Assembler keeps a table of these names so that if an instruction refers to it, the
Assembler can easily tell the location to which it was assigned.

3.It generates the machine code equivalent of the Assembly instructions.


15
INTERPRETER
o An interpreter translates a source program word by word or line by line.

o This allows the CPU to execute one line at a time.

o The Interpreter takes one line of the source program, translates it into a
machine instruction, and then it is immediately executed by the CPU.

o It then takes the next instruction, translates it into a machine instruction,


and then the CPU executes it, and so on.

o The translated line is not stored in the computer memory. Therefore, every
time the program is needed for execution, it has to be translated.
16
COMPILER

o A compiler translates the entire/whole source program into object code


at once, and then executes it in machine language code.

o These machine code instructions can then be run on the computer to


perform the particular task as specified in the high-level program.

o The process of translating a program written in a high-level source


language into machine language using a compiler is called
Compilation.

17
Compiler Cont’d…
o For a given machine, each language requires its own Compiler.

o E.g., for a computer to be able translate a program written in


FORTRAN into machine language; the program must pass through the
FORTRAN compiler (which must ‘know’ FORTRAN as well as the
Machine language of the computer).

18
FUNCTIONS OF A COMPILER
o It identifies the proper order of processing, so as to execute the process
as fast as possible & minimize the storage space required in memory.
o It allocates space in memory for the storage locations defined in the
program to be executed.
o It reads each line of the source program & converts it into machine
language.
o It checks for Syntax errors in a program. If there are no syntax errors, it
generates machine code equivalent to the given program.
o It combines the program (machine) code generated with the appropriate
subroutines from the library.
19
PROGRAMMING METHODOLOGY

o A Methodology is a system of methods with its orderly and


integrated collection of various methods, tools and
notations.

o Two most popular programming methodology are:


 Top-down methodology

 Bottom-up methodology

20
TOP-DOWN METHODOLOGY
o A top-down approach (is also known as step-wise design) is
essentially the breaking down of a system to gain insight into its
compositional sub-systems.

o Each subsystem is then refined in yet greater detail, sometimes in


many additional subsystem levels, until the entire specification is
reduced to base elements.

21
Top-Down Cont’d…
o Top-down-design starts with a description of the overall system
and usually consists of a hierarchical structure which contains
more detailed descriptions of the system at each lower level.

o The lower level design details continue until further subdivision is


no longer possible

22
BOTTOM-UP METHODOLOGY

o In a bottom-up approach the individual base elements of the


system are first specified in great detail.

o These elements are then linked together to form larger


subsystems, which then in turn are linked, sometimes in many
levels, until a complete top-level system is formed.

23

You might also like