INTRODUCTION TO PROGRTAMMING PARADIGMS |
To facilitate discussion of any subject it is desirable and convenient to group together similar facets of the subject according to some grouping notation. Computer programming are not an exception to this, however, there3 are many categorisations that we can adopt. The most common are as follows:
Before discussing this classification it is appropriate to remined ourselves of the operationb of a computer program. A computer program resides in the primary memory where it is represented as a set of machine instructions which in turn are represented as sequences of binary digits. At any point in time the computer is said to be in a particular state. A central feature of the state is the instruction pointer which points to the next machine instruction to be executed. The execution sequence of a group of machine instructions is known as the flow of control.
MACHINE CODE Thus, a program running on a computer is simply a sequence of bits. A program in this format is said to be in machine code. We can write programs in machine code:
23fc 0000 0001 0000 0040 0cb9 0000 000a 0000 0040 6e0c 06b9 0000 0001 0000 0040 60e8 |
ASSEMBLY LANGUAGE Assembly language (or assembler code) was our first attempt at producing a mechanism for writing programs that was more palatable to our selves. Of course a program wriiten in machine code, ibn order to "run", must first be translated (assembled) into nachine code.
movl #0x1,n compare: cmpl #oxa,n cgt end_of_loop acddl #0x1,n bra compare end_of_loop: |
HIGH LEVEL LANGUAGE From the foregoing we can see that assembler language is not much of an improvement on machine code! A more problem oriented (rather than machine oriented) mechanism for creating computer programs would also be desirable. Hence the advent of high(er) level languages commencing with the introduction of "Autocodes", and going on to Algol, Fortran, Pascal, Basic, Ada, C, Etc.
THE SOFTWARE CRISIS The phrase software crisis alludes to a set of problems encountered in the development of computer software during the 1960s when attempting to build larger and larger software systems using existing development techniques. As a result:
To address these problems the discipline of software engineering came into being.
STRUCTURED PROGRAMMING
The concept of structured programming devised in late 1960s (Dijkstra and others). Emphasizes programming using sequences, conditions and repetition (no jumps and "goto" statements). Constructs which have a predictable logic, i.e. they are entered at the top and exited at the bottom. Structured programming enhances readability and hence maintainability.MODULAR PROGRAMMING The concept of modular programming was first taken seriously in the early 1970s. Modular programming is concerned with sub-division of programs into manageable "chunks". The concept also encompasses ideas about levels of abstraction - modules are usually arranged in a hierarchy of abstraction. •Modularity also espouses the concept of information hiding.
INFORMATION HIDING Information hiding espouses the idea that the attention of programmers should not be distracted by details not central to their current programming task, i.e. programmers should not be required to be concerned with unnecessary details. In terms of modular programming modules should be designed so that information contained within those modules is "hidden" from other modules, e.g. implementational details of functions.
|
|
Languages can also be classified by the emphasis they put on "what is to be achieved" against "how it is to be achieved". The first are said to be declarative (e.g. functional and logic languages). The second is said to be non-declarative (e.g. imperative languages).
In science a paradigm describes a set of techniques that have been found to be effective for a given problem domain (i.e somebody somewhere must believe in it). A paradigm can typically be expressed in terms of a single principle (even if this is in fact an over simplification). This principle must be supported by a set of techniques. In the context of programming languages we say that a paradigm induces a particular way of thinking about the programming task. We can identify four principal programming paradigms:
PROGRAMMING MODELS The 4 main programming paradigms aim at solving general programming problems, but sometimes there are additional aspects to a problem which require us to "tweak" a paradigm. The result is not a new paradigm but a programming model founded on a particular paradigm. •An example is parallel or distributed programming.
Return to introduction home page or continue.
Created and maintained by Frans Coenen. Last updated 03 July 2001