Programming
paradigm mainly describes the way in which a particular computer
program should be written. According to Wikipedia, it is fundamental
style of computer programming.
Basically, different programming languages are designed to follow a particular paradigm or may be multiple paradigms.
Examples are: C, C++, Java, PHP, Python, Ruby etc.
Examples are : F#, Haskell, Lisp, Python, Ruby, JavaScript etc
The Functional Programming paradigm views all subprograms as functions in the mathematical sense, they take in arguments and return a single solution.
Advantages
The following are desirable properties of a functional language:
Disadvantages
The ability to use inheritance is the single most distinguishing feature of the OOP paradigm. Inheritance gives OOP its chief benefit over other programming paradigms - relatively easy code reuse and extension without the need to change existing source code.
The mechanism of modeling a program as a collection of objects of various classes, and furthermore describing many classes as extensions or modifications of other classes, provides a high degree of modularity.
Basically, different programming languages are designed to follow a particular paradigm or may be multiple paradigms.
Imperative(procedural) Programming Paradigm:
-- Imperative programming is a programming paradigm that uses statements that change a program's state. -- In much the same way that the imperative mood in natural languages expresses commands. -- An imperative program consists of commands for the computer to perform. -- Imperative programs describe the details of HOW the results are to be obtained.-- HOW means describing the Inputs and describing how the Outputs are produced.Examples are: C, C++, Java, PHP, Python, Ruby etc.
- Popular programming languages are imperative more often than
they are any other paradigm . There are two
reasons for such popularity:
- the imperative paradigm most closely resembles the actual machine itself, so the programmer is much closer to the machine;
- because of such closeness, the imperative paradigm was the only one efficient enough for widespread use until recently.
- the imperative paradigm most closely resembles the actual machine itself, so the programmer is much closer to the machine;
- Advantages
- efficient;
- close to the machine;
- popular;
- familiar.
- Disadvantages
- The semantics of a program can be complex to understand or prove, because of referential transparency does not hold(due to side effects)
- Side effects also make debugging harder;
- Abstration is more limitted than with some paradigms;
- Order is crucial, which doesn't always suit itself to problems.
Functional Programming Paradigm:
-- 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.Examples are : F#, Haskell, Lisp, Python, Ruby, JavaScript etc
The Functional Programming paradigm views all subprograms as functions in the mathematical sense, they take in arguments and return a single solution.
The following are desirable properties of a functional language:
- The high level of abstraction, especially when functions are used, supresses many of the details of programming and thus removes the possibility of commiting many classes of errors;
- The lack of dependence on assignment operations, allowing programs to be evaluated in many different orders. This evaluation order independence makes function-oriented languages good candidates for programming massively parallel computers;
- The absence of assignment operations makes the function-oriented programs much more amenable to mathematical proof and analysis than are imperative programs, because functional programs possess referential transparency.
- Perhaps less efficiencey.
- Problems involving many variables or a lot of sequential activity are sometimes easier to handle imperatively or with object-oriented programming.
Object Oriented Programming Paradigm:
-- Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which may contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods.-- There is significant diversity of OOP languages, but the most popular ones are class-based, meaning that objects are instances of classes, which typically also determine their type.-- In OOP, computer programs are designed by making them out of objects.
Examples are: C++, C#, Java, PHP, Python
Features & Benefits
A new class (called a derived class or subclass) may be derived from another class (called a base class or superclass) by a mechanism called inheritance. The derived class inherits
all the features of the base class: its structure and behavior. In addition, the derived class may contain additional
state (instance variables), and may exhibit additional behavior (new
methods to resond to new messages). Significantly, the derived class
can also override behavior corresponding to some of the methods of the base class: there would be a different method to respond to the same message. Also, the inheritance mechanism is allowed even without access to the source code of the base class.
The ability to use inheritance is the single most distinguishing feature of the OOP paradigm. Inheritance gives OOP its chief benefit over other programming paradigms - relatively easy code reuse and extension without the need to change existing source code.
The mechanism of modeling a program as a collection of objects of various classes, and furthermore describing many classes as extensions or modifications of other classes, provides a high degree of modularity.
Declarative Programming Paradigm:
- The Declarative Paradigm takes a approach to
problem-solving. Various logical assertions about a situation are made,
establishing all known facts. Then queries are made. The role of the
computer becomes maintaining data and logical deduction.
Example: SQL, CSS.
Comments
Post a Comment