Levels of Programming Languages: Machine Languages (1 Generation Languages)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

LEVELS OF PROGRAMMING LANGUAGES

There are many programming languages. The languages are classified into 2 major categories:
1). Low-level programming languages.
2). High-level programming languages.
Each programming language has its own grammatical (syntax) rules, which must be obeyed in
order to write valid programs, just as a natural language has its own rules for forming sentences.

LOW-LEVEL LANGUAGES
These are the basic programming languages, which can easily be understood by the computer
directly, or which require little effort to be translated into computer understandable form.
They include:
1. Machine languages.
2. Assembly languages.
Features of low-level languages
 They are machine hardware-oriented.
 They are not portable, i.e., a program written for one computer cannot be installed and used
on another computer of a different family.
 They use Mnemonic codes.
 They frequently use symbolic addresses.
st
Machine languages (1 Generation languages)
Machine language is written using machine codes (binary digits) that consist of 0‟s & 1‟s.
The computer can readily understand Machine code (language) instructions without any
translation.
A programmer is required to write his program in strings of 0‟s & 1‟s, calculate & allocate the
core memory locations for his data and/or instructions.
Different CPU‟s have different machine codes, e.g., codes written for the Intel Pentium
processors may differ from those written for Motorola or Cyrix processors. Therefore, before
interpreting the meaning of a particular code, a programmer must know for which CPU the
program was written.
A machine code instruction is made up of 2 main parts;
(i). An Address (operand):
It specifies the location (address) of the computer memory where the data to be worked
upon can be found.
(ii). A Function (operation) code:
It states to the Control Unit of the CPU what operation should be performed on the
data/item held in the address, e.g., Addition, Subtraction, Division, Multiplication, etc.
Note. The computer can only execute instructions which are written in machine language. This
is because; it is the only language which the computer can understand. Therefore, any program
written in any other programming language must first be translated into machine language
(binary digits) before the computer can understand.
nd
Assembly language (2 Generation Languages).
Assembly languages were developed in order to speed up programming (i.e., to overcome the
difficulties of understanding and using machine languages).
The vocabulary of Assembly languages is close to that of machine language, and their
instructions are symbolic representations of the machine language instructions.
 Assembly language programs are easier to understand, use & modify compared to Machine
language programs.
 Assembly language programs have less error chances.
To write program statements in Assembly language, the programmer uses a set of symbolic
operation codes called Mnemonic codes.
The code could be a 2 or 3 shortened letter word that will cause the computer to perform specific
operation. E.g., MOV – move, ADD - addition, SUB – subtraction, RD - read.
Example;
RD PAT, 15 (read the value 15 stored in the processor register named PAT)
SUB PAT, 10 (subtract 10 from the value in register PAT)
A program written in an Assembly language cannot be executed/obeyed by the computer
hardware directly. To enable the CPU understand Assembly language instructions, an
Assembler (which is stored in a ROM) is used to convert them into Machine language.
The Assembler accepts the source codes written in an Assembly language as its input, and
translates them into their corresponding computer language (machine code/ object code)
equivalent.
Comments are incorporated into the program statements to make them easier to be understood by
the human programmers.
Assembly languages are machine-dependent. Therefore, a program written in the Assembly
language for a particular computer cannot run on another make of computer.

Advantages of Low-level languages


1. The CPU can easily understand machine language without translation.
2. The program instructions can be executed by the hardware (processor) much faster. This is
because; complex instructions are already broken down into smaller simpler ones.
3. Low-level languages have a closer control over the hardware, are highly efficient & allow
direct control of each operation.
They are therefore suitable for writing Operating system software & Game programs, which
require fast & efficient use of the CPU time.
4. They require less memory space.
5. Low-level languages are stable, i.e., they do not crash once written.
Disadvantages of Low-level languages
Very few computer programs are actually written in machine or Assembly language because of
the following reasons;
1. Low-level languages are difficult to learn, understand, and write programs in them.
2. Low-level language programs are difficult to debug (remove errors from).
3. Low-level languages have a collection of very detailed & complex instructions that control
the internal circuiting of the computer. Therefore, it requires one to understand how the
computer codes internally.
4. Relating the program & the problem structures is difficult, and therefore cumbersome to
work with.
5. The programs are very long; hence, writing a program in a low-level language is usually
tedious & time consuming.
6. The programs are difficult to develop, maintain, and are also prone to errors (i.e., it requires
highly trained experts to develop and maintain the programs).
7. Low level languages are machine-dependent (specific), hence non-portable.
This implies that, they are designed for a specific machine & specific processor, and
therefore, cannot be transferred between machines with different hardware or software
specifications.
8. It is not easy to revise the program, because this will mean re-writing the program again.

HIGH-LEVEL PROGRAMMING LANGUAGES


High-level languages were developed to solve (overcome) the problems encountered in low-level
programming languages.
The grammar of High-level languages is very close to the vocabulary of the natural languages
used by human beings. Hence; they can be read and understood easily even by people who are
not experts in programming.
Most high-level languages are general-purpose & problem-oriented. They allow the programmer
to concentrate on the functional details of a program rather than the details of the hardware on
which the program will run.
High-level language programs are machine-independent, (i.e., they do not depend on a particular
machine, and are able to run in any family of computers provided the relevant translator software
is installed).
Programs written in a high-level language cannot be obeyed by the computer hardware directly.
Therefore, the source codes must be translated into their corresponding machine language
equivalent. The translation process is carried out by a high-level language software translator
such as a Compiler or an Interpreter.
Features of high-level programming languages.
 They contain statements that have an extensive vocabulary of words, symbols, sentences &
mathematical expressions, which are very similar to the normal English language.
Example;
Read (TaxablePay);
IF TaxablePay<1000 THEN
Tax: =0;
ELSE
Tax: =TaxRate * TaxablePay;
Write (Tax: 6:2);
 Allow modularization (sub-routines).
 They are „user-friendly‟ and problem-oriented rather than machine-based. This implies that,
during a programming session, the programmer concentrates on problem-solving rather than
how a machine operates.
 They require one to be obey a set of rules when writing the program.
 Programs written in high-level languages are shorter than their low-level language
equivalents, since one statement translates into several machine code instructions.
 The programs are portable between different computers.

Purpose of High-level languages.


1. To improve the productivity of a programmer. This is because; the source programs of high-
level languages are shorter than the source programs of low-level languages, since one
statement translates into several machine code instructions.
2. To ease the training of new programmers, since there is no need to learn the detailed layout
of a procession/sequence.
3. To speed up testing & error correction.
4. To make programs easy to understand & follow.
Advantages of High-level languages.
1. They are easily portable, i.e., they can be transferred between computers of different
families and run with little or no modification.
2. High-level language programs are short, and take shorter time to be translated.
3. They are easy to lean, understand and use.
4. They are easy to debug (correct/remove errors), & maintain.
5. High level language programs are easy to modify, and also to incorporate additional features
thus enhancing its functional capabilities.
6. They are „user-friendly‟ & problem-oriented; hence, can be used to solve problems arising
from the real world.
7. They enable programmers to adapt easily to new hardware. This is because; they don‟t have
to worry about the hardware design of the computer.
8. High-level language programs are self-documenting, i.e., the program statements displays the
transparency of purpose making the verification of the program easy.
9. High level languages are more flexible; hence, they enhance the creativity of the programmer
and increase his/her productivity in the workplace.

Disadvantages of using High-level languages


1. High-level languages are not machine-oriented; hence, they do not use of the CPU and
hardware facilities efficiently.
2. The languages are machine-independent, and cannot be used in programming the hardware
directly.
3. 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.
4. Their program statements are too general; hence, they execute slowly than their machine
code program equivalents.
5. They have to be interpreted or compiled to machine-readable form before the computer can
execute them.
6. The languages cannot be used on very small computers.
The source program written in a high-level language needs a Compiler, which is loaded into
the main memory of the computer, and thus occupies much of memory space. This greatly
reduces the memory available for a source program.

TYPES OF HIGH-LEVEL LANGUAGES.


High-level languages are classified into five different groups:
1. Third generation languages (Structured / Procedural languages).
2. Fourth generation languages (4GLs).
3. Fifth generation languages (5GLs)
4. Object-oriented programming languages (OOPs).
5. Web scripting languages.
The various types of high-level languages differ in:
 The data structures they handle.
 The control structures they support.
 The assignment instructions they use.
 Application areas, e.g., educational, business, scientific, etc.
STRUCTURED LANGUAGES
A structured (procedural) language allows a large program to be broken into smaller sub-
programs called modules, each performing a particular (single) task. This technique of program
design is referred to as structured programming.
Structured programming also makes use of a few simple control structures in problem solving.
The 3 basic control structures are:
 Sequence
 Selection.
 Iteration (looping).
Advantages of structured programming.
1. It is flexible.
2. Structured programs are easier to read.
3. Programs are easy to modify because; a programmer can change the details of a section
without affecting the rest of the program.
4. It is easier to document specific tasks.
5. Use of modules that contain standard procedures throughout the program saves development
time.
6. Modules can be named in such a way that, they are consistent and easy to find in
documentation.
7. Debugging is easier because; each module can be designed, coded & tested independently.
Examples of Third generation programming languages include:
1). BASIC (Beginners All-purpose Symbolic Instructional Code).
BASIC is a simple general-purpose high-level language used in most computer processing
tasks such as developing business and educational applications.
It is easy to learn & use; hence, suitable for students who wish to easily learn programming.
Translation in most versions of BASIC is carried out by an Interpreter.
Disadvantages of BASIC.
 BASIC is available in so many versions with different dialects/languages & therefore, it
has no standard.
 Some dialects are limited to data & control structures they support.
 Some versions of BASIC offer limited facilities in terms of structured programming &
meaningful variable names.
2). PASCAL
PASCAL is a general-purpose, high-level programming language, which was named after a
French mathematician called Blaise Pascal.
It was developed as an academic tool to help in the teaching and learning of structured
programming.
PASCAL supports structured programming, i.e., it uses procedures & functions, which allow
a „top-down‟ approach to solving problems.
 It is not easy to learn because; it has strict rules in its grammar on typing of variables
(data names) & declarations.
 It is poor (has limited ability) on handling of data files.
3). COBOL (COmmon Business Oriented Language)
COBOL is designed for developing programs that solve business problems, e.g., can be used
to develop commercial data processing applications such as computer-based inventory
control systems.
COBOL is mostly used where large amounts of data are to be handled, because it supports
powerful data & control structures.
COBOL programs are semi-compiled, and the intermediate code is interpreted.
A program written in COBOL language consists of 4 divisions: -
(i). Identification division: Where the programmer & the program details are specified,
e.g., program ID, programmer name, etc.
(ii). Environment division: Where the equipments to be used by the source & the object
programs are defined, e.g., the computer hardware.
(iii). Data division: Where the various files to be used by the program are described, e.g.,
a description of the input files.
(iv). Procedure division: Where all the procedures required to manipulate/interrelate the
data into information are defined.
Advantages of COBOL.
 It is easy to read.
 It is portable, i.e., can be used on different types of computers. This is because; it has an
American National Institute standard.
American National Standards Institute (ANSI): – An international organization that
devised/ invented the group of standardized symbols used in flowcharting.
 It is widely used, and has a pool of skilled programmers.
Disadvantage of COBOL.
 The structure of a COBOL program is too long even for simple programs.
E.g., consider the following assignment statement:
DIVIDE A into B giving C.
This statement when used in BASIC language can much short „C=A/B‟. However,
notice that the COBOL statement above is more self defining.
4). FORTRAN (FORmula TRANslator)
It was developed for mathematicians, scientists and engineers. It provides an easier way of
writing scientific & engineering applications.
FORTRAN statements are mostly in form of mathematical expressions; hence, it is useful in
writing of programs that can process numeric data.
FORTRAN programs are compiled.
Advantages of FORTRAN.
 It is portable, i.e. it can be used on different types of computers.
Disadvantage of FORTRAN.
 It is not suited for business applications.
5). Ada
This language was named after the first lady programmer Ada Lovelace.
It is suitable for developing military, industrial and real-time systems.
6). C
C is mainly used for developing system software such as the operating system as well as
developing the application packages.
It has powerful commands that permit the rapid development of programs, and allows direct
control over the hardware.
Disadvantage of C
 It is difficult to read & learn because of its strict dialect rules.
7). LOGO
LOGO was designed for educational use in which children can explore & develop concepts
through programming the movement of a pen.
8). COROL
COROL is used in Real-time processing.
COROL programs are compiled.
9). RPG (Report Program Generator)
RPG is used in report generating applications, (i.e. it is designed to facilitate the output of
reports of business data).
A Report generator is a software tool that extracts stored data to create customized reports
that are not normally/usually produced by existing applications.
10). SNOBOL (String Oriented Symbolic Language).
It is a high-level language designed to manipulate strings of characters. It is therefore used
for non-numeric applications.

FOURTH GENERATION LANGUAGES (4GL’S).


4GLs make programming even easier than the 3GLs because; they present the programmer with
more programming tools, such as command buttons, forms, textboxes etc. 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.
The languages also use application generators (which in the background) to generate the
necessary program codes; hence, the programmer is freed from the tedious work of writing the
code.
4GLs are used to enquire & access the data stored in database systems; hence, they are described
as the Query languages.
Purpose of fourth generation languages.
The 4GL‟s were designed to meet the following objectives: -
1. To speed up the application-building process, thereby increasing the productivity of a
programmer.
2. To enable quick & easy amendments and alteration of programs.
3. To reduce development & maintenance costs.
4. To make languages user-friendly. This is because, the 4GL‟s are designed to be user-
oriented, unlike the 3rd generation languages which are problem & programmer oriented.
5. To allow non-professional end-users to develop their own solutions.
6. To generate bug-free codes from high-level expressions of requirements.
Examples of 4GLs are:
 Visual Basic
 Delphi Pascal
 Visual COBOL (Object COBOL)
 Access Basic
Advantages of fourth generation languages.
1. They are user-based, and therefore, easy to learn & understand.
2. The grammar of 4GL‟s is very close to the natural English language. It uses menus &
prompts to guide a non-specialist to retrieve data with ease.
3. Very little training is required in order to develop & use 4GL programs.
4. They provide features for formatting of input, processing, & instant reporting.

FIFTH GENERATION LANGUAGES (5GL’S).


The 5GL‟s are designed to make a computer solve a problem by portraying human-like
intelligence.
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. 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.
5GLs are mostly used in artificial intelligence.
Examples of 5GLs are:
 PROLOG
 LISP
 Mercury
 OCCAM.
1). LISP (LISt Processing)
In LISP, both programs & data are arranged (structured) as lists.
It is used in artificial intelligence. However, it is not suitable for commercial data
processing applications.
2). PROLOG (PROgramming in LOGic)
PROLOG was developed from LISP by the Japanese.
It is designed for use with Expert systems & Artificial Intelligence. It is mostly used for
solving problems, which involve objects and relationships between objects.
Like LISP, it is not suitable for commercial data processing applications.

OBJECT-ORIENTED PROGRAMMING LANGUAGES (OOPs)


Object-Oriented Programming is a new approach to software development in which data &
procedures that operate on data are combined into one object.
OOPs use objects. An Object is a representation of a software entity such as a user-defined
window or variable. Each object has specific data values that are unique to it (called state) and a
set of the things it can accomplish called (functions or behaviour).
Several objects can be linked together to form a complete program. Programs send messages to
an object to perform a procedure that is already embedded in it. This process of having data and
functions that operate on the data within an object is called encapsulation.
The data structure & behaviour of an object is specified/described by a template (called a class).
Classes are hierarchical, and it is possible to pass the data & behaviour of an object in one class
down the hierarchy.
Object-Oriented programming enables rapid program development. Every object has properties
such as colour, size, data source, etc, which can be set easily without much effort. In addition,
every object has events associated with it that can be used to trigger certain actions, e.g. remove
the window from the screen on clicking the „Close‟ button.
OOP has contributed greatly to the development of graphical user interface operating systems
and application programs.
Examples of Object-oriented programming languages are: -
 Simula
 C++
 SmallTalk
 Java
Java is sometimes associated with development of websites, but it can be used to create whole
application programs that do not need a web browser to run.

JAVA
Java is an OOP language that resembles Object C (a simplified form of C++).
The code of Java displays graphics, accesses the network, and interfaces with users via a set of
capabilities known as classes. Classes define similar states & common methods for the behavior
of an object.
JAVA programs are not compiled into machine code; instead, they are converted into a
collection of bytes that represent the code for an abstract Java Virtual machine (VM). A Java
interpreter running on a physical machine is then used to translate those bytes into local actions,
such as printing a string or drawing a button.

WEB SCRIPTING LANGUAGES.


Web scripting languages are mostly used to create or add functionalities on web pages.
Web pages are used for creating Web sites on the Internet where all sorts of advertising can be
done.
Web pages are hypertext (plain-text) documents written using a language called HyperText
Markup Language (HTML). HTML documents have a file extension of .Html or .Htm.
Note. HTML doesn‟t have the declaration part and control structures, and has many limitations.
Therefore, to develop functional websites, it must be used together with other web scripting
languages like JavaScript, VBScript and Hypertext Preprocessor.

Comparison of Programming languages.

Machine language Assembly language High-level languages


1. Instruction set is made up 1. Instruction set is made up of 1. Instruction set is similar to
& mathematical operators.

2. Instruction is made of 2 2. Instruction is made up of 2 2. The instruction varies


parts: operation code & parts: operation code & depending on the particular
be added.
operand. operand, but comments can language.
3. No translation is needed. 3. Uses an Assembler to 3. Uses compiler or interpreter
(This is the computer convert the assembly Compiler translates all the
language; hence, the language source codes to source code at once into
computer understands it their object code equivalents object code; Interpreter
4. Executed by the hardware 4. Executed faster than High- 4. Translation & execution is
directly & is faster. level, but slower than the very slow.
machine code programs.
5. Difficult to learn, develop 5. It‟s easier to learn, develop 5. Easy to learn, develop,
& maintain. & maintain as compared to maintain and use.
machine code programs.
6. Programs are lengthy & 6. Like machine code 6. Programs are shorter &
tedious. language, the programs are simpler than Machine &
lengthy & tedious. assembly lang. programs.
7. It is time-consuming to 7. They take a shorter time to 7. Developing High-level
develop machine code develop as compared to language programs takes
programs. machine code programs, but very short time.
take longer than High-level
language programs.
8. Used in applications where 8. Like machine language, 8. Most High-level languages
efficient use of the CPU Assembly language are general-purpose, & can
time is necessary, e.g., programs are used in be used to do almost all
developing Operating applications where efficient computer-processing tasks.
systems & other Control use of the CPU time is
programs that coordinate necessary.
the working of peripherals.

Factors to consider when choosing a Programming language.


The following factors should be considered when choosing a Programming language to use in
solving a problem:
1). The availability of the relevant translator
2). Whether the programmer is familiar with the language
3). Ease of learning and use
4). Purpose of the program, i.e., application areas such as education, business, scientific, etc.
5). Execution time
Applications that require quick response are best programmed in machine code or assembly
language. High-level languages are not suitable for such application because, they take long
to be translated & executed.
6). Development time
Development time is the time a programmer takes to write and run a program.
High-level languages are easy to read, understand and develop; hence, they require less
development time. Machine code & Assembly languages are relatively difficult to read,
understand and develop; hence, they are time-consuming.
7). Popularity
The language selected should be suitable and/or successful in the market with respect to the
problems to be solved.
8). Documentation
It should have accompanying documentation (descriptions) on how to use the language or
maintain the programs written in the language.
9). Maintenance
Programs are developed to solve specific problems, and the problems keep on changing;
hence, the programs are also changed to perform the new functions.
Program maintenance is the activity of incorporating more routines onto the program,
modifying the existing routines or removing the obsolete routines to make the program
adapt to a functionally enhanced environment.
The maintenance is made easier if the language used is easy to read and understand.
10). Availability of skilled programmers
The language selected should have a pool of readily available programmers to ease
the programming activity, and reduce development time.

Review Questions
1. (a). What is a Programming language?
(b). Explain the two levels of programming languages.
2. (a). What is meant by „Machine language‟?
(b). Explain why machine language programming is so error-prone.
(c). Show the difference between Machine language and Assembly language.
(d). Give two advantages & three disadvantages of Machine language programming.
3. (a). What are High-level languages?
(b). Give the features/characteristics of high-level programming languages.
(c). Describe briefly how a program written in high-level programming language
becomes a machine code program ready for operational use.
(d). Explain the advantages and disadvantages of using a High-level programming
language for writing a program.
(e). List four examples of high-level programming languages. Indicate the application
of each language in computing.
4. (a). What is meant by program portability?
(b). Why are low-level languages not considered to be portable?
5. List 8 factors that need to be considered when selecting a programming language.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy