You are on page 1of 9

LECTURE 2.

Foundation of sequential programming CSC 210

COMPUTER / PROGRAMMING LANGUAGES

Computer or Programming Languages are sets of words, symbols and codes used to write
programs. Different programming languages are available for writing different types of
programs. Some languages are specially used for writing business programming, others
are used for writing scientific program etc.
There are three types or levels of computer programming:

1. Machine language

2. Low level Languages

3. High Level Languages

Machine language

Machine Language is the actual bits used to control the processor in the computer,
usually viewed as a sequence of hexadecimal numbers (typically bytes). The processor
reads these bits in from program memory, and the bits represent "instructions" as to what
to do next. Thus machine language provides a way of entering instructions into a
computer (whether through switches, punched tape, or a binary file).

Machine Language instruction has two (2) parts. The first part is the operation code
which tells the computer what function to perform and the second part is the operand
which tells the computer where to find or store the data which is to be manipulated. A
programmer needs to write numeric codes for the instruction and storage location of data.

Characteristics of Machine Language:

1. It is the first generation programing language

2. It is much difficult than Assembly Language

3. Difficult to understand by the human


4. It is in the form of 0s and 1s

5. Machine Language varies from platform

6. It cannot be changed easily

7. It does not support modification

8. The risk of existence of error is high


9. The binary code cannot be memorized

10. No need of compiler

Disadvantages of Machine Language

1. It is machine dependent, that is, it differs from computer to computer

2. It is difficult to program and write

3. It is prone to errors

4. It is difficult to modify.

Low Level Languages

A low-level programming language is a programming language that provides little or


no abstraction from a computer's instruction set architecture—commands or functions in
the language map closely to processor instructions. The word "low" refers to the small or
nonexistent amount of abstraction between the language and machine language; because
of this, low-level languages are sometimes described as being "close to the hardware".

Low level programming languages are languages that will let you have direct access
on the machine resources (CPU Registers, Memory, I/O ports, etc)

Examples of Low Level Languages are:

1. Assembly Language

2. C (By comparing it to Assembly, It’s high level language but contains low level
features, so by many programmers it’s called portable assembly, and by comparing it
to scripting languages, it’s low level language)

3. We can add other languages that are similar to C or support low level features provided
by C, like C++, but remember that C++ comes with more high level features than C like
Object-Oriented, Better standard library, Templates, etc

So it depends not only on the language, but how we are using it.
Some programs written in C, don’t use the low level features, these programs looks like
it was written in high-level language, because in C we have the language constructs that
help in Abstraction too!

Assembly Language

Assembly (or assembler) language, often abbreviated as asm is a more human readable
view of machine language. Instead of representing the machine language as numbers, the
instructions and registers are given names (typically abbreviated words, or mnemonics,
eg ld means "load", ADD means addition, SUB means subtraction etc). Unlike a high
level language, assembly language is very close to the machine language that is why it is
also called symbolic machine code. The main abstractions (apart from the mnemonics)
are the use of labels instead of fixed memory addresses, and comments. Each assembly
language is specific to a particular computer architecture.

Example:

instead of using “1100 000”, we write the symbol ADD to mean the same thing(addition)

Assembler.

Assembler is an example of computer utility program which converts or translates


assembly language into executable machine. It assembles the machine language program
in the main memory of the computer and makes it ready for execution.

The conversion process is referred to as assembly, or assembling the source code.


Assembly time is the computational step where an assembler is run.

A disassembler performs the reverse function (although the comments and the names of
labels will have been discarded in the assembler process).

Characteristics of Assembly Language:

1. It is a second generation programming language

2. It is less difficult than machine language


3. Easy to understand by the human

4. It uses symbolic instructions, descriptive names for data items and


memory location

5. The Assembly Language is platform dependent

6. It is easily Modifiable

7. The risk of occurrence of error is reduced

8. Memorability is high

9. It needed a compiler to run which is known as assembler

10. One instruction per line.

11. Labels provide names for addresses (usually in first column).

12. Instructions often start in later columns.

13. Columns run to end of line.

Advantages of Assembly Language

1. It is easy to understand and use

2. It is easy to locate and correct errors

3. It is easier to modify

4. Speed - Assembly language programs are generally the fastest programs around.

- Machine language created by compilers are usually longer and this makes
them slower.

5. Space - Assembly language programs are often the smallest.

6. Capability - You can do things in assembly which are difficult or impossible in


HLLs.
- Applications requiring access to low level machine capability are often written
in assembly language, example device drivers.

7. Knowledge

- Your knowledge of assembly language will help you write better programs,
even when using HLLs.

- Assembly language requires learning the architecture of the specific machine


on which assembly language is used

Disadvantages of Assembly Language

It is also a machine dependent language

High Level Languages

High Level Languages are the types of computer programming languages close to human
languages, they are combinations of English language-like instructions such as input,
print etc and mathematical symbols. A program written in HLL are easier to write and
modify.

Each statement in a HLL is a micro instruction which is translated into several machine
language instructions.

A compiler is a translator program which translates a HLL programming language into


equivalent machine language programs. It compiles a set of machine language
instructions for every HLL program.

HLL are further divided into the following categories:

1. Procedural Languages

2. Object Oriented Languages

3. Non-Procedural Languages
1. Procedural Programming languages Procedural programming are also known
as third generation language of 3G. in these language, program is a predefined set
of instructions. Computer executes these instructions in the same sequence in
which the instructions are written. Each instruction in this language tells the
computer what to do and how to do it. Some popular PL are: FORTRAN, BASIC,
COBOL, PASCAL, C etc

2. Object Oriented Programming

OOP is a technique in which programs are written on the basis of object. An object is a
collection of data and functions. Objects may represent a person, thing or place in real
world, in OOP, data and all possible functions on data are grouped together. Object
Oriented programs are easier to learn and modify. C++ and Java are popular Object
Oriented Language.

Characteristics of OOP

The following are the characteristics of OOP:

1. Object

2. Classes

3. Real world modeling

4. Reusability: through the use of inheritance

5. Information hiding- using encapsulation function

6. Polymorphism

3. Non-Procedural Language

NPL are also known as fourth generation language or 4GL. In NPL, user only needs to
tell the computer “what to do” not “How to do it”. An important advantage of NPL is that
they can be used by NP user to perform a specific task. These languages accelerates
program process and reduce coding errors. 4GL are normally used in database application
and report generation. Some important non-procedural languages are as follows:

1. SQL (Sequential Query Language) e.g MySQL

2. RPG (Report Program Generator) e.g Crystal Report

Advantages of High-Level Languages

1. They are machine independent

2. They are easier to learn and use

3. They are easier to read and write

4. They are easier to maintain and gives few errors.

Execution modes

There are three general modes of execution for modern high-level languages:

Interpreted

When code written in a language is interpreted, its syntax is read and then
executed directly, with no compilation stage. A program called an interpreter
reads each program statement, following the program flow, then decides what to
do, and does it. A hybrid of an interpreter and a compiler will compile the
statement into machine code and execute that; the machine code is then discarded,
to be interpreted anew if the line is executed again. Interpreters are commonly the
simplest implementations of the behavior of a language, compared to the other
two variants.

Compiled

When code written in a language is compiled, its syntax is transformed into an


executable form before running. There are two types of compilation:

Machine code generation


Some compilers compile source code directly into machine code. This is the
original mode of compilation, and languages that are directly and completely
transformed to machine-native code in this way may be called "truly compiled"
languages.

Source-to-Source Translated or Trans-compiled

Code written in a language may be translated into terms of a lower-level


programming language for which native code compilers are already widely
available. JavaScript and the C programming language are common targets for
such translators.

Note that languages are not strictly "interpreted" languages or "compiled" languages.
Rather, implementations of language behavior use interpretation or compilation. For
example, Algol 60 and Fortran have both been interpreted (even though they were more
typically compiled).

High-level language computer architecture

Alternatively, it is possible for a high-level language to be directly implemented by a


computer – the computer directly executes the HLL code. This is known as a high-
level language computer architecture – the computer architecture itself is designed to
be targeted by a specific high-level language.

Assignment

1. List the differences between Assembly language and Machine Language

2. List the differences between HLLs and Low LLs.

3. Draw a diagram of how computer translates(using translator) a source code

4. Draw a diagram of how computer compiles(using compiler) a source code

You might also like