Programming paradigm
A programming paradigm is a fundamental style of computer programming. (Compare with a methodology, which is a style of solving specific software engineering problems). Paradigms differ in the concepts and abstractions used to represent the elements of a program (such as objects, functions, variables, constraints, etc.) and the steps that compose a computation (assignation, evaluation, continuations, data flows, etc.).
Contents |
Overview
A programming language can support multiple paradigms. For example programs written in C++ or Object Pascal can be purely procedural, or purely object-oriented, or contain elements of both paradigms. Software designers and programmers decide how to use those paradigm elements.
In object-oriented programming, programmers can think of a program as a collection of interacting objects, while in functional programming a program can be thought of as a sequence of stateless function evaluations. When programming computers or systems with many processors, process-oriented programming allows programmers to think about applications as sets of concurrent processes acting upon logically shared data structures.
Just as different groups in software engineering advocate different methodologies, different programming languages advocate different programming paradigms. Some languages are designed to support one particular paradigm (Smalltalk supports object-oriented programming, Haskell supports functional programming), while other programming languages support multiple paradigms (such as Object Pascal, C++, C#, Visual Basic, Common Lisp, Scheme, Python, Ruby and Oz).
Many programming paradigms are as well known for what techniques they forbid as for what they enable. For instance, pure functional programming disallows the use of side-effects; structured programming disallows the use of the goto statement. Partly for this reason, new paradigms are often regarded as doctrinaire or overly rigid by those accustomed to earlier styles.[citation needed] Avoiding certain techniques can make it easier to prove theorems about a program's correctness—or simply to understand its behavior.
History
Initially, computers were programmed using binary code that represented control sequences fed to the computer CPU. This was difficult and error-prone. Programs written in binary are said to be written in machine code, which is a very low-level programming paradigm.
To make programming easier, assembly languages were developed. These replaced machine code functions with mnemonics and memory addresses with labels. Assembly language programming is also a low-level paradigm although it is a second generation paradigm. Although assembly language is an improvement over machine code, it is still prone to errors, and difficult to debug and maintain.
The next advance was the development of procedural languages. These third-generation languages, the first described as high-level languages, use vocabulary related to the problem being solved. For example, COBOL (Common Business Oriented Language) uses terms like file, move and copy.
FORTRAN (FORmula TRANslation) and ALGOL (ALGOrithmic Language) were developed mainly for scientific and engineering problems, although one of the ideas behind the development of ALGOL was that it was an appropriate language to define algorithms. BASIC (Beginners All purpose Symbolic Instruction Code) was developed to enable more people to write programs. All these languages follow the procedural paradigm. That is, they describe, step by step, exactly the procedure that should be followed to solve a problem.
The problem with procedural languages is that it can be difficult to reuse code and to modify solutions when better methods of solution are developed. In order to address these problems, object-oriented languages (like Eiffel, Smalltalk and Java) were developed. In these languages data, and methods of manipulating the data, are kept as a single unit called an object. The only way that a user can access the data is via the object's methods. This means that, once an object is fully working, it cannot be corrupted by the user. It also means that the internal workings of an object may be changed without affecting any code that uses the object.
A further advance was made when declarative programming paradigms were developed. In these languages the computer is told what the problem is, not how to solve the problem. Given a database the computer searches for a solution. The computer is not given a procedure to follow as in the languages discussed so far.
Another programming paradigm is functional programming. Programs written using this paradigm use functions, which may call other functions (including themselves). These functions have inputs and outputs. Variables, as used in procedural languages, are not used in functional languages. Functional languages make a great deal of use of recursion.
Hierarchy of programming paradigms
- Agent-oriented programming
- Component-based software engineering (as in OLE)
- Concatenative programming
- Concurrent computing
- Context-oriented programming (as in ContextJ/ContextS/ContextL)
- Declarative programming, contrasted with imperative programming
- Functional programming (as in Lisp, Scheme and Haskell)
- Goal-directed programming as in Snobol
- Event-driven programming
- Feature-oriented programming
- Function-level programming, contrasted with value-level programming
- Imperative programming, contrasted with declarative programming
- Advanced separation of concerns
- Aspect-oriented programming (as in AspectJ)
- Subject-oriented programming (as in Hyper/J)
- Array programming, contrasted with scalar programming
- Automata-based programming
- Object-oriented programming
- Class-based programming (as in Smalltalk and Eiffel)
- Prototype-based programming (as in Self)
- Procedural programming
- Role-oriented programming
- Scalar programming, contrasted with array programming
- Advanced separation of concerns
- Iterative programming, contrasted with recursive programming
- Metaprogramming
- Attribute-Oriented Programming (as in Java 5 Annotations, pre-processed by the XDoclet class; C# Attributes)
- Reflective programming
- Generative programming
- Generic programming
- Language-oriented programming through the creation and subsequent use of domain-specific languages to solve a specific problem
- Nondeterministic programming
- Parallel computing
- Recursive programming, contrasted with iterative programming
- Tree programming
- Value-level programming, contrasted with function-level programming
See also
- Paradigm
- Mindset
- Turing completeness
- Multi-paradigm programming language
- Domain-specific language
- Programming domain
- Architecture description language
- Modeling language
References
External links
|
|
|
|