High Level Programming Languages

advertisement
LOW LEVEL
LANGUAGES
Almost, but not quite machine code.
FEATURES
1. CPU specific, making direct use
of internal registers.
2. ‘Mnemonics’ used as
programming code, e.g. ADD or
MULT.
3. Many different memory modes
can be used.
4. Labels are used as reference
points to allow the code to jump
from one part to another.
These came before PROCEDURAL LANGUAGES.
E.g. Assembly Language
2nd Generation - these
languages were
developed as the second
stage. Before this,
computers could only
communicate in binary
(machine code), but low
level languages
introduced the use of
assembly language – using
labels and mnemonics.
PROS
1. Excellent for close control of the
CPU – many device drivers are
coded in assembly language.
2. Very efficient – well-optimised
code can be made to run very
quickly compared to other
programming paradigms.
CONS
1. Difficult to use – programming
commands can be obscure.
2. Programmer needs to know a lot
of detail about the internal
structure of the CPU.
3. Produces the least portable
source code.
PROCEDURAL
LANGUAGES
Sometimes called IMPERATIVE
languages.
Procedural languages
are 3rd generation
languages:
FEATURES
This makes it easier for
people to read and
understand code, using
ideas such as naming
variables and using
functions and
subroutines to partition
the code into
manageable chunks
1. One of the most common
programming paradigms in use.
2. Code specific instructions for the
computer to carry out – ‘do this,
then this’ etc.
3. Instructions are laid out in
sequence.
4. Imperative means ‘to give orders’ –
all about telling the computer what
to do, step by step.
E.g. C
These came after LOW LEVEL
LANGUAGES.
They came before OBJECT ORIENTED
LANGUAGES
PROS
1. Less complicated than OOP
2. Problem oriented – use terms
appropriate to the type of
problem being solved – relatively
easy to understand
CONS
1. Easy to write faulty code, when
all instructions are just written
out in sequence, rather than
sensibly grouped.
2. Difficult to reuse code in other
programs
OBJECT ORIENTED
PROGRAMMING
LANGUAGES
FEATURES
1. Makes use of classes and objects.
2. Classes and objects are manipulated
through their internal methods.
3. Main idea of OOP languages is to
gather the data and all
methods/functions that act on that
data into one entity/class.
PROS
1. Classes can be treated as black boxes – other coders only
need to know how to manipulate them through their
methods, not how they work.
2. Easier to provide working code – class can be fully tested
and released for other coders for use.
3. Many ‘design patterns’ available for common programming
tasks – saves time, as a coder can simply pick one up and
start work on it straight away.
4. Code portability – just need the right compiler for the target
CPU, and the source code can be run on an entirely different
hardware platform.
5. Code re-use – easy to move classes between applications /
projects.
E.g. Java, E.g. C++
CONS
These came after PROCEDURAL
LANGUAGES.
1. Steep learning curve – takes a long time to become proficient in OOP as
it’s more complicated than standard procedural language.
2. Complex – the programmer needs skill.
3. Not as compact and efficient as writing code directly in low level
language.
They came before DECLARATIVE
LANGUAGES.
DECLARATIVE
LANGUAGES
These came after OBJECT
ORIENTED LANGUAGES.
E.g. Prolog
FEATURES
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Non-procedural
Very high level – 4th generation.
Programmer specifies what needs to be done, rather than how to do it.
Software will seek an answer to the question (goal) by interrogating a
database containing facts and rules.
Doesn’t matter what order the facts and rules are stored in – computer
finds the best path towards the answer.
Goal = query, e.g. male(X)
Instance = a specific occurrence of a fact, e.g. male(John)
Instantiation = assigning values to arguments of a predicate
Arguments = objects that need to be checked in a predicate statement,
e.g. wife(David, Mary) – David and Mary are arguments of ‘Wife’
Predicate = a logic statement that will be checked to determine if it’s
true or false. If it’s true, a specific value will be returned.
Backtracking = going back to a previously found successful match to
continue the search for an answer.
PROS
1. The programmer doesn’t
need to know how the
computer is going to find
the answer – it only needs
to tell it what it needs to
find.
CONS
1. Programmer needs to be
competent in using this
type of language to create
a program that will make
efficient use of the CPU.
FUNCTIONAL
LANGUAGES
Almost, but not quite machine code.
These languages are not in the
specification, but it’s useful to know
about them.
E.g. Mathematica
A powerful functional
language to solve
mathematical problems.
Has a clear syntax with
which to write
mathematical statements.
FEATURES
5. Most concerned with providing
answers to problems purely
through applying calculations to
input data.
6. Have no ‘side effects’ – don’t
change anything other than the
input data provided at that time.
E.g. LISP
Short for ‘List Processing’.
Developed as an efficient
way of coding calculations.
Specialises in carrying out
calculations and operations
across data stored as linked
lists.
PROS
3. Excellent for close control of the
CPU – many device drivers are
coded in assembly language.
4. Very efficient – well-optimised
code can be made to run very
quickly compared to other
programming paradigms.
CONS
4. Difficult to use – programming
commands can be obscure.
5. Programmer needs to know a lot
of detail about the internal
structure of the CPU.
6. Produces the least portable
source code.
UML
Class Diagrams – 3 rectangles showing class, attributes and methods
Object Diagrams – 2 rectangles showing a specific object of a class and
its data
Anonymous Object =
Use Case Diagrams – stick figures with a use case in between them – the
use case
Communication Diagrams – rectangles with arrows between showing
data flow, and they are labelled with the information being shared
State Diagrams –rounded rectangles showing states of a job. Circles
are the entry and exit points of the system. Arrows are transitions, and
events are known as ‘triggers’
Sequence Diagrams – show how objects interact with each other.
Rectangles are objects. Dotted lines underneath the objects are ‘lifelines’.
The thin rectangles are where methods associated with the object are
activated to do something. Homework has a finite life. Objects can be
anonymous or specific.
Activity Diagrams – flow diagrams showing the activities necessary to get
the object into a particular state.
Starting point
Activity
More than
one activity
being done at
a time
Decision
Input to
Output from
End of diagram
Download