Programming paradigm

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 (assignment, evaluation, continuations, data flows, etc.).

Contents

Overview

A programming model is an abstraction of a computer system. For example, the "von Neumann model" is a model used in traditional sequential computers. For parallel computing, there are many possible models typically reflecting different ways processors can be interconnected. The most common are based on shared memory, distributed memory with message passing, or a hybrid of the two.

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++, Java, C#, Visual Basic, Common Lisp, Scheme, Perl, Python, Ruby, Oz and F Sharp).

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, while 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.[1] Avoiding certain techniques can make it easier to prove theorems about a program's correctness—or simply to understand its behavior.

Multi-paradigm programming language

A multi-paradigm programming language is a programming language that supports more than one programming paradigm. As Leda designer Timothy Budd puts it: "The idea of a multiparadigm language is to provide a framework in which programmers can work in a variety of styles, freely intermixing constructs from different paradigms." The design goal of such languages is to allow programmers to use the best tool for a job, admitting that no one paradigm solves all problems in the easiest or most efficient way.

An example is Oz, which has subsets that are logic (Oz descends from logic programming), a functional, an object-oriented, a dataflow concurrent, and other language paradigms. Oz was designed over a ten-year period to combine in a harmonious way concepts that are traditionally associated with different programming paradigms. A programming paradigm provides for the programmer the means and structure for the execution of a program.

History

Initially, computers were hard-wired and then later 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. The transfer from Hardwired to Machine code represents the implementation of the Von Neumann machine. A hardwired system reflects a machine with a transfer function for the data between input and output. The function is created by the wiring and components between the two. A later machine incorporates the Stored Program concept exemplified by a Von Neumann machine where data and program are both stored in the same machine. In the Von Neumann machine each program represents a different hard wired machine. The program defining the transfer function for data.

To make programming easier, assembly languages were developed. These replaced machine code functions with mnemonics and memory addresses with symbolic labels. Assembly language programming is considered a low-level paradigm although it is a 'second generation' paradigm. Even assembly languages of the 1960s actually supported library COPY and quite sophisticated conditional macro generation and pre-processing capabilities. They also supported modular programming features such as CALL (subroutines), external variables and common sections (globals), enabling significant code re-use and isolation from hardware specifics via use of logical operators as READ/WRITE/GET/PUT. Assembly was, and still is, used for time critical systems and frequently in embedded systems.

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,

  • C - developed circa 1970 at Bell Labs
  • COBOL (Common Business Oriented Language) - uses terms like file, move and copy.
  • FORTRAN (FORmula TRANslation) - using mathematical language terminology, it was developed mainly for scientific and engineering problems.
  • ALGOL (ALGOrithmic Language) - focused on being an appropriate language to define algorithms, while using mathematical language terminology and targeting scientific and engineering problems just like FORTRAN.
  • PL/I (Programming Language One) - a hybrid commercial/scientific general purpose language supporting pointers.
  • 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, according to the particular programmer at least, be followed to solve a specific problem. The efficacy and efficiency of any such solution are both therefore entirely subjective and highly dependent on that programmer's experience, inventiveness and ability.

Later, object-oriented languages (like Simula, Smalltalk, Eiffel and Java) were created. 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' (subroutines). Because of this, the internal workings of an object may be changed without affecting any code that uses the object. There is still some controversy by notable programmers such as Alexander Stepanov, Richard Stallman[2] and others, concerning the efficacy of the OOP paradigm versus the procedural paradigm. The necessity of every object to have associative methods leads some skeptics to associate OOP with software bloat. Polymorphism was developed as one attempt to resolve this dilemma.

Since object-oriented programming is considered a paradigm, not a language, it is possible to create even an object-oriented assembler language. High Level Assembly (HLA) is an example of this that fully supports advanced data types and object-oriented assembly language programming - despite its early origins. Thus, differing programming paradigms can be thought of as more like 'motivational memes' of their advocates - rather than necessarily representing progress from one level to the next. Precise comparisons of the efficacy of competing paradigms are frequently made more difficult because of new and differing terminology applied to similar (but not identical) entities and processes together with numerous implementation distinctions across languages.

Within imperative programming, an alternative to the computer-centered hierarchy of structured programming is literate programming, which structures programs instead as a human-centered web, as in a hypertext essay – documentation is integral to the program, and the program is structured following the logic of prose exposition, rather than compiler convenience.

Independent of the imperative branch based on procedural languages, declarative programming paradigms were developed. In these languages the computer is told what the problem is, not how to solve the problem - the program is structured as a collection of properties to find in the expected result, not as a procedure to follow. Given a database or a set of rules, the computer tries to find a solution matching all the desired properties. The archetypical example of a declarative language is the fourth generation language SQL, as well as the family of functional languages and logic programming.

Functional programming is a subset of declarative programming. Programs written using this paradigm use functions, blocks of code intended to behave like mathematical functions. Functional languages discourage changes in the value of variables through assignment, making a great deal of use of recursion instead.

The logic programming paradigm views computation as automated reasoning over a corpus of knowledge. Facts about the problem domain are expressed as logic formulae, and programs are executed by applying inference rules over them until an answer to the problem is found, or the collection of formulae is proved inconsistent.

See also

References

  1. ^ Frank Rubin published a criticism of Dijkstra's letter in the March 1987 CACM where it appeared under the title 'GOTO Considered Harmful' Considered Harmful. Frank Rubin (March 1987). "'GOTO Considered Harmful' Considered Harmful" (PDF). Communications of the ACM 30 (3): 195–196. doi:10.1145/214748.315722. http://www.ecn.purdue.edu/ParaMount/papers/rubin87goto.pdf. 
  2. ^ "Mode inheritance, cloning, hooks & OOP (Google Groups Discussion)". http://groups.google.com/group/comp.emacs.xemacs/browse_thread/thread/d0af257a2837640c/37f251537fafbb03?lnk=st&q=%22Richard+Stallman%22+oop&rnum=5&hl=en#37f251537fafbb03. 

External links

Programming language
lists

Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • programming paradigm — programavimo paradigma statusas T sritis informatika apibrėžtis Programos veikimo esminių bruožų apibrėžimas programuotojo požiūriu. Pavyzdžiui, objektinio programavimo paradigma reiškia, kad programos veikimas pagrįstas objektų sąveika, o… …   Enciklopedinis kompiuterijos žodynas

  • Programming language — lists Alphabetical Categorical Chronological Generational A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that… …   Wikipedia

  • Programming language theory — (commonly known as PLT) is a branch of computer science that deals with the design, implementation, analysis, characterization, and classification of programming languages and programming language features. It is a multi disciplinary field, both… …   Wikipedia

  • Programming Complexity — Programming Complexity, which is often also referred to as Software Complexity is a term that encompasses numerous properties of a piece of software, all of which affect internal interactions. According to several commentators, including… …   Wikipedia

  • Paradigm (disambiguation) — A paradigm is a key model, pattern or method (to achieve certain class of goals/objectives). Frequently it is a most characteristic or fundamental property of a theory or a branch of science.Depending on context, it may refer to:* (in philosophy… …   Wikipedia

  • Paradigm — For other uses, see Paradigm (disambiguation). The word paradigm (  /ˈpær …   Wikipedia

  • Programming by demonstration — (PbD) is a technique for teaching acomputer or a robot new behaviors by demonstrating the task totransfer directly instead of programming it through machinecommands.The term Programming by example (PbE) or Programming bydemonstration (PbD)… …   Wikipedia

  • Programming by example — (also known as Programming by Demonstration or more generally as Demonstrational Programming ) is a technique for teaching a computer new behavior by demonstrating actions on concrete examples. The system records user actions and infers a… …   Wikipedia

  • Object-oriented programming — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computing …   Wikipedia

  • List of programming languages by category — Programming language lists Alphabetical Categorical Chronological Generational This is a list of programming languages grouped by category. Some languages are listed in multiple categories. Contents …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”