Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
39 views

Section 8 - Program Implementation

Uploaded by

nisean19
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Section 8 - Program Implementation

Uploaded by

nisean19
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

SECTION 8:

PROGRAM IMPLEMENTATION
1
Distinguish between low-level
and high- level programming
languages;
Computer Program

A computer program is a set of instructions that tell a


computer what to do and how to do it.

There is only one programming language that any


computer can actually understand and execute: its own
binary machine code. The CPU interprets this code in
order to carry out the instructions of the program.

There are many programming languages that are


broken into two categories: low-level languages and
high-level languages.
Programming
Languages
● Low Level languages - these languages are machine
dependent i.e. the code written can only be understood by the
particular computer or processor that was used to write the
code.
○ E.g. Machine or Assembly Language

● High Level Languages - use keyword similar to English and


are easier to write. Unlike low level languages they are not
machine dependent (programs written on one computer can
generally be used on another similar computer).
○ E.g. Pascal, C, Visual Basic
5th Generation
Programming
Languages
(Natural
Language/AI)

4GLs
(4th Generation)

High Level Language


(3rd Generation)

Assembly Language (2nd Generation)

Machine Language (1st Generation)


First Generation Language
The first generation language, called machine language, uses the
digits 0 or 1 that make up the binary code.

An instruction might be written as 10110000 01100001.


First Generation Language
Advantages:
• Able to be executed very fast by the computer, as there is no need for
translation.

Disadvantages:
• Difficult to read, write and understand by humans as the programs
involve only 0’s and 1s
• Machine dependent, so unable to be used on another machine
• Difficult to modify or correct mistakes
Second Generation Language
The second generation language called assembly language;
instructions are written using mnemonics or abbreviated forms of
word.

Example it uses words like ADD for addition and SUB for subtraction.

It needs an assembler to convert from assembly language to machine


language.
Second Generation Language
Advantages:
• Easier to read, write and understand than machine level languages
• Easier to modify or correct mistakes than machine level languages

Disadvantages:
• Slower in execution than machine-level languages
• Still machine dependent
Third Generation Language
Third generation languages (3GLs) use statements in English that are
easy for programmers to use.

These languages are converted to machine code, rather like translating


from one language to another, so that the computer can carry out the
instructions in the CPU.
Third Generation Language
Examples are FORTRAN, BASIC, Pascal and C, C++, Java, Visual
Basic, Javascript.

Advantages:
• Easier to read, write and understand than low level languages
• Easier to modify or correct mistakes than low level languages.
• Machine independent

Disadvantages:
• Slower in execution than low level languages because it has to be
Fourth Generation Language
Fourth generation languages (4GLs) are considered advanced
high-level languages.

These are languages that consist of statements that are similar to


statements in the human language and are much more user friendly
than third generation languages. These are used mainly in database
programming and scripting.
Fourth Generation Language
E.g. SQL (Structured Query Language), Oracle, Python, Ruby

An instruction would look like FIND ALL RECORDS WHERE NAME IS


"SMITH"

Advantage:
• useful for generating reports

Disadvantage:
• can become very wordy
Fifth Generation Language
Fifth generation languages (5GLs) instructions are used in a
conversational way so it is also called natural language programming.
5GL are designed to make the computer solve the problem to you.

It only require the programmer to write the goals that have to be achieved
and not the sequence of steps to solve a problem. The computer would
solve the problem – it works out the required steps.

E.g. of a command: GIVE ME THE TOTAL NUMBER OF ITEMS


PURCHASED BY CUSTOMERS FROM BARBADOS.

5GLs are used in artificial intelligence where computers are given qualities of
a human.
Fifth Generation Language
Prolog and Mercury are fifth generation languages.

Advantage: computers will be able to communicate in natural spoken


language with their users

Disadvantage: very complex to design, programmer must be highly trained.


(a) Describe ONE advantage and ONE disadvantage of EACH of the following:
(i) Low level languages (2 marks)
(ii) High level languages (2 marks)
(b) Name TWO programming languages which belong to EACH of the
categories. (4 marks)
2
Describe the sequence of
steps in implementing a
program;
∙ Step 1 - Create source code
o Source code - a program written in a given computer language. It is a computer
program in its original, human-readable form.
∙ Step 2 - Translate and/or link
o Source code has to be translated into machine code. This is done by translators
(assemblers, compilers, interpreters).
▪ Compiler – for high level languages, a compiler translates all program
instructions at one time and produces object code which is then executed.
Object code is the program, in machine code, that is the output of source code
being compiled.
▪ Interpreter – converts a high-level program one line at a time and executes it
immediately.
▪ Assembler – converts assembly language to machine language
o Linking – this is the process of combining together individual object code files to
form a single executable program (a program that is ready to run by a computer
system).
∙ Step 3 - Execute program
o Executing - to run the program.
∙ Step 4 - Maintain program
o Maintain program – is the process of making any
modifications that may need to be made to a
developed program to make it suitable for a
particular situation
3
Perform checks and
tests on programs to
verify correctness;
Testing - process used to verify that a program meets it's specify
requirements and to detect errors. You must first compile the program. You
will find all syntax errors when you compile the program. To test the logic of
the program you must use appropriate test data which you know the
resulting answer(s) for before running it through the program.

Test data – is values in a program to determine if it produces the required


results. It is used to the test a program for logic errors. When selecting test
data to desk check an algorithm, you must look at the program specification
and choose simple test cases only.

Debugging - the finding and correcting of errors that exist in your program.
Types of Errors
Syntax error -an error caused by incorrect use of a language violating the rules
governing the structure of it. These errors are found during compilation. It may be
the misspelling of a word or the opening of a command without closing it.

Logic errors – is when the program does not produce the required results due to
incorrect logic. This error cannot be detected by the compiler, it can be detected
when the program is run; using appropriate test data and the actual output doesn't
match the required output. Logic errors are usually the hardest to debug because
they do not cause the program to fail completely.

Run-time error – occurs when the program has to terminate before its completion.
Such as division by 0.
6
Effectively document
programs.
It is important to have
clear documentation of
your program so that
others can follow it
easily, whether they are
other programmers or
users of the program.
Internal documentation – appears inside the
program
• meaningful variable names
• descriptive comments
• indentation
• effective use of white space
External documentation – is created separately and supplied with the
program
• Technical documentation – contains the technical aspects of the
program such as version, the operating system that it can work with, the
amount of memory and hard disk space required and installation
procedure
• User documentation (user manual) – suggest how the users should
use the program to solve some simple program errors; it contains
instructions on how to start and stop the program and using the program.
Can be in the form of a written booklet or online tutorial with FAQs
(Frequently Asked Questions)

You might also like