News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Paradigms of Programming Languages

Started by sukishan, Jul 12, 2009, 06:00 PM

Previous topic - Next topic

sukishan

Paradigms of Programming Languages

Although many different computer architectures are being developed, the most prevalent is still the traditional von Neumann architecture - consisting of a single sequential CPU separate from memory, with data piped between cpu and memory. This is reflected in the design of the dominant computer languages, with dynamic variables (representing memory cells with changing values); sequential iteration (reflecting the single sequential cpu); assignment statements (reflecting piping). This combination of choices gives rise to the imperative language paradigm - C, Ada, Pascal, FORTRAN, COBOL, Basic etc.

But other choices are possible - variables do not have to directly reflect memory cells (logic programming); repetition need not be iterative (logic, functional, concurrent); assignment need not be important (logic, functional); data and control need not be separated (object oriented, functional).

A paradigm is essentially a high level model of what computation is about - the unifying factor that makes Ada and C seem very similar, ignoring details such as what data or control structures are available, exactly how variables are passed to procedures, and so on.


Some Paradigms

Procedural (COBOL, FORTRAN, Pascal, C)
functional (LISP)
logic (PROLOG)
structured
object-oriented (Smalltalk)
4GL (Dbase)
Visual (Visual Basic)
1 Procedural

This is focusing on grouping organizations and/or code by similar operations or by the operations that can be done on them.

2 Functional

Functional programming is so called because a program consists entirely of functions. The program itself is written as a function which receives the program's input as its argument and delivers the program's output as its result. Typically the main function is defined in terms of other functions, which in turn are defined in terms of still more functions, until at the bottom level the functions are language primitives. These functions are much like ordinary mathematical functions.

Functional programs contain no assignment statements, so variables, once given a value, never change. Functions can be described intentionally by a rule describing the association, or extensionally as a set of associated pairs (argument, result) which are called the graph of the function. Functional programming also provides greater abstraction for solution. One such a feature is polymorphism which allows general definition of functions which could be applied to objects of any type. To achieve such a behavior we use type variables which stand for any type. Further higher order functions provide facility to treat functions as a data objects and use them like other data objects. It means that function (higher order function) can manipulate and create other functions. Another important feature of the functional programming is that evaluation of arguments could be delayed but done at most once. This technique is called lazy evaluation. Postponing sometimes can lead to such a situation that postponed value could be found as not necessary to evaluate, even when argument is undefined. If such a function can return a defined result we call it non-strict, else if returns undefined is called strict.

3 Logic

The basic constructs of logic programming, terms and statements are inherited from logic. There are three basic statements: facts, rules and queries. There is a single data structure: the logical term.

In a logic programming language the logical relationship between various entities are declared. The programmer writes a database of facts and rules. The user supplies a queries (goals) which the system tries to prove. This involves matching the current goal against each fact or the left hand side of each rule using unification. If the goal matches a fact, the goal succeeds; if it matches a rule then the process recurses, taking each sub-goal on the right hand side of the rule as the current goal. If all sub-goals succeed then the rule succeeds.

Logic programming languages tend to be declarative programming languages, as opposed to the more traditional imperative programming languages. In a declarative language, you concentrate on the relationships between the parts of the problem, rather than on the exact sequence of steps required to solve the problem. An example of a well-known declarative languages are SQL, Prolog.
A good beginning makes a good ending