0% found this document useful (0 votes)
51 views4 pages

Cpe 201 - Lecture

Uploaded by

JOSHUA ENIAYEKAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views4 pages

Cpe 201 - Lecture

Uploaded by

JOSHUA ENIAYEKAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

COURSE TITLE: PROGRAMMING IN ENGINEERING

COURSE CODE: CPE 201


SUBTITLE: LANGUAGE PROCESSOR AND TYPES OF PROGRAMMING LANGUAGES

LANGUAGE PROCESSORS
Language Processor is special translator system software which is used to translate the program
written in high-level language or middle-level language into machine code. This system software
can be any of the following three types:

1. Assembler
The Assembler is a translator used to translate the program written in Assembly language
into machine code. The source program is an input of assembler that contains assembly
language instructions. The output generated by the assembler is the object code or machine
code understandable by the computer.

2. Compiler
This is a kind of translator which read the complete source program written in high level
language as a whole and translates it into an equivalent program in machine language.
Examples: C, C++, C# and Java. In a compiler, the source code is translated to object code if
it is free of errors. It specifies the errors at the end of compilation with line numbers where
there are errors in the source code. Compiler can successfully recompile the source code
when the errors have been removed.

3. Interpreter
This is a kind of translator which translates source program line by line into machine code
and executes it immediately before moving on to the next line of codes. If there is an error in
a line statement, the interpreter terminates the process and displays an error message. It can
only move on to the next line for execution only after removal of error. Examples: Perl,
Python and Matlab.

Difference between Compiler and Interpreter

Compiler Interpreter
Compiler takes large amount of time to analyze Interpreter takes less amount of time to analyze
the entire source code but the overall execution the source code but the overall execution time of
time of the program is comparatively faster. the program is slower.
Generates intermediate object code No intermediate object code is generated.

It converts the entire source code of a It takes a source program and runs it line by line
programming language into executable machine translating each line as it comes to it
code for a CPU
It generates the error message only after Its debugging is easier as it continues translating
scanning the whole program. So debugging is the program until the error is met
comparatively hard as the error can be present
anywhere in the program

TYPES OF PROGRAMMING LANGUAGE AND PROGRAMMING PARADIGMS

Programming language is a language which is used in writing a set of instructions to control


the activities of a computer system e.g PYTHON, PASCAL, COBOL etc. There are two main
types of computer programming languages. They are:
1. Low level language
2. High level language
LOW LEVEL LANGUAGE
This is a type of programming language which is closer to the machine compared with the human
natural language. The two major examples are Machine language and Assembly language.

1. Machine Language: This is the only language computer understands. The computer
directly executes a program written in machine language. Such programs are coded using
strings of O’s and 1’s. It doesn’t need a translator.

Advantage of Machine Language


1. It uses computer storage more efficiently
2. It takes less time to process in a computer than any other programming language

Disadvantage of Machine Language


Some of the disadvantages of Machine Language include:
1. Very bulky.
2. They require much time for writing and reading.
3. They are prone to error which is difficult to be detected and corrected.
4. Very difficult learn.
5. Can only run on the computer it is designed for (machine dependent)

2. Assembly Language: Assembly Language uses MNEMONICS (symbols) to represent data and
instructions. This language eliminates problems associated with machine language. Computer
cannot execute directly a program written in assembly language, it requires a translator called
assembler. Assembler is a special program designed to translate a program content in assembly
language to a machine language equivalent.

Advantages of Assembly Language


1. It is more efficient than machine language
2. Symbols make it easier to use than machine language
3. It may be useful for security reasons

Disadvantages of Assembly Language


These include:
1. It is machine dependent; programmer has to be knowledgeable in both subject area and the
operations of the machine.
2. It is cumbersome though less cumbersome than that of machine language.
3. Very expensive to develop.
4. It consumes time.

HIGH LEVEL LANGUAGE


A high level language is a problem oriented programming language, whereas a low level language
is machine oriented. The source programs are written in human readable languages like English
instead of mere symbols. In otherwords, a high level language is a convenient and simple means of
describing the information structures and sequences of actions required to perform a particular task.

Advantages of High Level Language


These include:
1. The person writing the program does not need to know anything about the computer in
which the program will be run (Machine Independent).
2. The programs are portable.
3. Very easy to learn and write

Disadvantages of High Level Language


1. It takes more time to process in a computer than any other programming language

Features of High Level Language


1. Machine independent
2. Problem oriented
3. Ability to reflect clearly the structure of program written in it.
4. Readability
5. Programs are portable
Examples of High level Languages are FORTRAN, COBOL, QBASIC, VISUAL BASIC, JAVA ,
ADA, and PASCAL e.t.c.

Characteristics of a Good Program


1. Transferability- Must be able to work on any computer machine.
2. Reliability- It can be relied upon to do what it is expected to do.
3. Efficiency / cost saving- It must not cost more than its benefits and enables problem to be
solved appropriately, quickly and efficiently.
4. Simplicity- It should be as simple as possible to understand.
5. Understandability / Readability- It must be readable and understandable by other
programmers and end users.
6. Flexibility / Adaptability / Maintainability- A good program must be flexible adaptable and
maintainable in order to suit user’s need. Modification must be possible and very easy.

PROGRAMMING PARADIGM

The term programming paradigm refers to a style of programming. It does not refer to a specific
language, but rather it refers to the way you program. It can take any of the following forms.
1. Declarative programming: It is a style of building programs that expresses the logic of a
computation without talking about its control flow. It is a programming paradigm in which
the programmer defines what needs to be accomplished by the program without defining
how it needs to be implemented. In other words, the approach focuses on what needs to be
achieved instead of instructing how to achieve it.
2. The Functional programming paradigm has its roots in mathematics and it is language
independent. The key principle of this paradigm is the execution of a series of mathematical
functions. You compose your program of short functions. All code is within a function. All
variables are scoped to the function. In this paradigm, the functions do not modify any
values outside the scope of that function and the functions themselves are not affected by
any values outside their scope. Languages that support functional programming paradigm:
JavaScript, Scala etc.
3. Procedural programming allows splitting instructions into procedures. Procedures aren't
functions. The difference between them is that functions return a value, and procedures do
not. More specifically, functions are designed to have minimal sideeffects, and always
produce the same output when given the same input. Procedures, on the other hand, do not
have any return value. Their primary purpose is to accomplish a given task and cause a
desired side effect. A great example of procedures would be the well-known “for loop”. The
for loop's main purpose is to cause side effects and it does not return a value.
4. Object-oriented programming paradigm (OOP) : OOP is the most popular programming
paradigm because of its unique advantages like the modularity of the code and the ability to
directly associate real-world business problems in terms of code. The key characteristics of
object-oriented programming include Class, Abstraction, Encapsulation, Inheritance and
Polymorphism.
The main concepts of object-oriented programming are:
1. Abstraction
2. Encapsulation
3. Inheritance
4. Polymorphism

Abstraction

Abstraction means using simple things to represent complexity. We all know how to turn the TV on,
but we don’t need to know how it works in order to enjoy it. In OOP, abstraction means simple
things like objects, classes, and variables represent more complex underlying code and data. This is
important because it lets avoid repeating the same work multiple times.

Encapsulation

Encapsulation describes the ability of an object to hide its data and methods from the rest of the
world and is one of the fundamental principles of object-oriented programming. In OOP, a class
encapsulates the fields, which hold the state of an object, and the methods, which define the actions
of the object. Encapsulation enables you to write reusable programs. It also enables you to restrict
access only to those features of an object that are declared public. All other fields and methods are
private and can be used for internal object processing.

Inheritance

Inheritance is an important feature of object-oriented programming languages. It enables classes to


include properties of other classes. The class that inherits the properties is called a child class or
subclass, and the class from which the properties are inherited is called a parent class or superclass.
This feature also helps in reusing already defined code.

Polymorphism

Polymorphism is the ability for different objects to respond differently to the same message. In
object-oriented programming languages, you can define one or more methods with the same name.
These methods can perform different actions and return different values. The forms of
polymorphism are overloading and overriding.

ALGORITHM AND PSEUDO-CODE

An Algorithm is a finite series of unambiguous instructions that when given a set of input values
produce a desired result. A desirable property of an algorithm is that it is easy to translate into a
programming language. Pseudo-code is an informal way to express the design of a computer
program or an algorithm.

You might also like