programming concepts- week 1
programming concepts- week 1
Generally, a computer is made of the hardware part and the software part.
The physical /tangible components that a computer is made of are referred to as the
computer’s hardware. Hardware components include; mouse, keyboard, harddisk,
memory, speakers, earphones etc.
Software/ program is a set of instructions that tell the hardware components how to
perform the required task.
A computer program is an ordered set of instructions that a computer executes to
accomplish a given task.
For every function or task a computer performs, there is a certain program behind it.
For example, to type a document using your laptop, you need a Ms word or any other
word processor. To do computations, you need Ms Excel or any other spreadsheet
program. To browse internet, you need chrome, Firefox, safari or any other browser.
To watch or play music, you need VLC or any other audio or video play program
A program is written to provide a solution to a specific problem.
Computer programs are written by professionals known as programmers or software
developers.
To write a program, a programmer a programming language of choice among various
languages that exist in the market.
A programming language is a set of symbols, grammars and rules with the help of
which one is able to translate algorithms to programs that will be executed by the
computer. The programmer communicates with a machine using programming
languages
Each programming language contains a unique set of keywords and syntax, which are
used to create a set of instructions.
These languages vary in the level of abstraction (hiding the complexity) they provide
from the hardware. Some programming languages provide less or no abstraction while
some provide higher abstraction.
Generally, computer programming languages can be divided into two types i.e. Low-
level Language, and High-level Language.
I. Low-level Language
Provides no abstraction from the hardware, and it is represented in 0 or 1
forms, which are the machine instructions.
Hardware dependent
Difficult to understand
Low-level Language can be further divided into two categories,
Machine Language: The code written in machine language is in the
Binary format(0 & 1) the format that is understood by the CPU.
Creating a program in a machine-level language is a very difficult task
as it is not easy for programmers to write the program in machine
instructions.
It is error-prone as it is not easy to understand, and its maintenance is
also very high.
A machine-level language is not portable as each computer has its
machine instructions, so if we write a program on one computer will
no longer be valid on another computer.
1
Assembly Language: The use of assembly language uses mnemonics
codes instead of machine language instructions.
The assembly language contains some human-readable commands
such as mov, add, sub, etc.
Since assembly language instructions are written in English words like
mov, add, sub, so it is easier to write and understand.
However, a translator known as an assembler is required to convert the
instructions written in assembly language into machine language.
II. High-level Languages
They allow a programmer to write programs that are independent of a
particular type of computer.
They are considered high-level because they are closer to human
languages than machine-level languages.
Their codes are easy to read, write and debug as they are similar to
English-like statements.
A compiler is required to translate a high-level language into a low-level
language.
Compilation is the process in which the compiler program translates the
instructions of a high level language to a machine level language.
A separate compiler is required for every high level language.
High level language is cannot be executed in their source(source
program). It need to be compiled (translated) to machine level language
program called object program for that machine by the compiler. Such
compilers are called selfresident compilers and every high-level language
has a selfresident compiler.
High-level Language can be further divided into three categories.
Procedural Language: Code in the procedural language is a
sequential step-by-step procedure, that gives information like what to
do and how to do it. Such languages include Fortran, Cobol, Basic, and
C.
Declarative Language: allow the programmer to specify what needs
to be done, but does not specify how it should be done. Such languages
include SQL and Prolog. SQL allows the programmer to define the
result they wish to achieve, without specifying how the results will be
retrieved.
Object-oriented Language: allows the use of objects and the
associated methods and attributes when writing a program. Such
Languages include C++, Java, and Python.
Designing a Program
A computer program is a product.
Thus, just like any other product that undergoes production, a program should be
designed first before coding.
The design should clearly outline the program’s algorithm (a step-by-step sequence
of solving a given problem).
Before writing the actual program using any programming language, a programmer
can design/outline the flow of the program instructions using pseudocode or a
flowchart
i. Pseudocode is an informal way of writing the flow a program.
2
It only represents the algorithm of the program in natural language and
mathematical notations.
Pseudocode can be developed using simple English language statements.
After writing the pseudocode, you now write the actual program to
implement the pseudocode
For example
Start
Input number1
Input number2
Compute total = number1 + number 2;
Print total;
End