Sunteți pe pagina 1din 9

PROGRAMMING PARADIGMS

Rupinder Kaur and Inderdeep Kaur


Department Of Computer Science & Engineering
Institute of Engineering & Technology, Bhaddal (Ropar) Punjab
Mandeep Kaur(Department GGS college of Modern technology (Kharar)
Email: - talktorupinder@yahoo.co.in,kaur.inderdeep@gmail.com,
er.deepvasantia@tgmail.com

Abstract-A programming paradigm is a of side-effects; structured programming


fundamental style of programming disallows the use of go to. Partly for this
regarding how solutions to problems are reason, new paradigms are often regarded
to be formulated in a programming as doctrinaire or overly rigid by those
language. A programming paradigm accustomed to earlier styles. However, this
provides (and determines) the view that avoidance of certain techniques can make
the programmer has of the execution of the it easier to prove theorems about a
program. For instance, in object-oriented program's correctness—or simply to
programming, programmers can think of a understand its behavior—without limiting
program as a collection of interacting the generality of the programming
objects, while in functional programming language.
a program can be thought of as a
sequence of stateless function evaluations. The relationship between programming
When programming computers or systems paradigms and programming languages
with many processors, process oriented can be complex since a programming
programming allows programmers to language can support multiple paradigms.
think about applications as sets of For example, C++ is designed to support
concurrent processes acting upon elements of procedural programming,
logically shared data structures. Just as object-oriented programming and generic
different groups in software engineering programming. However, designers and
advocate different methodologies, different programmers decide how to build a
programming languages advocate program using those paradigm elements.
different programming paradigms. Some One can write a purely procedural
languages are designed to support one program in C++, one can write a purely
particular paradigm while other object-oriented program in C++, or one
programming languages support multiple can write a program that contains elements
paradigms. of both paradigms A programming
paradigm is a fundamental style of
1. INTRODUCTION Computer programming. (Compare with a
methodology, which is a style of solving
Many programming paradigms are as well specific software engineering problems).
known for what techniques they forbid as A programming language can support
for what they enable. For instance, pure multiple paradigms. For example
functional programming disallows the use programs written in C++ can be purely
procedural, or purely object-oriented, or The following are some standard
contain elements of both paradigms. terminology used in Aspect-oriented
Software designers and programmers programming:
decide how to use those paradigm
elements. Cross-cutting concerns: Even
2. Categories of Programming though most classes in an OO model will
paradigms perform a single, specific function, they
often share common, secondary
The various categories of programming requirements with other classes. For
paradigms are: example, we may want to add logging to
classes within the data-access layer and
Aspect-oriented programming also to classes in the UI layer whenever a
Functional programming thread enters or exits a method. Even
Generic programming though the primary functionality of each
Logic programming class is very different, the code needed to
Object-oriented programming perform the secondary functionality is
Service-oriented programming often identical.
Advice: This is the additional code
2.1. Aspect-oriented programming that you want to apply to your existing
n software engineering, the programming model. In our example, this is the logging
paradigms of aspect-oriented code that we want to apply whenever the
programming (AOP), and aspect-oriented thread enters or exits a method.
software development (AOSD) attempt to Point-cut: This is the term given to
aid programmers in the separation of the point of execution in the application at
concerns, specifically cross-cutting which cross-cutting concern needs to be
concerns, as an advance in modularization. applied. In our example, a point-cut is
AOP does so using primarily language reached when the thread enters a method,
changes, while AOSD uses a combination and another point-cut is reached when the
of language, environment, and method. thread exits the method.
Separation of concerns entails breaking Aspect: The combination of the
down a program into distinct parts that point-cut and the advice is termed an
overlap in functionality as little as aspect. In the example below, we add a
possible. All programming logging aspect to our application by
methodologies—including procedural defining a point-cut and giving the correct
programming and object-oriented advice.
programming—support some separation 2.2 Functional programming
and encapsulation of concerns (or any area Functional programming is a
of interest or focus) into single entities. programming paradigm that treats
For example, procedures, packages, computation as the evaluation of
classes, and methods all help programmers mathematical functions and avoids state
encapsulate concerns into single entities. and mutable data. It emphasizes the
But some concerns defy these forms of application of functions, in contrast with
encapsulation. Software engineers call the imperative programming style that
these crosscutting concerns, because they emphasizes changes in state. Functional
cut across multiple modules in a program. languages include APL, Erlang, Haskell,
Terminology Lisp, ML, F# and Scheme. Functional
programming languages, especially purely nothing; typically, purity is used to enforce
functional ones, have largely been a separation of concerns where one
emphasized in academia rather than in clearly-delineated section of the program
commercial software development. does impure operations like I/O, and calls
However, notable functional programming pure functions and libraries as needed to
languages used in industry and compute answer.
commercial applications include Erlang
(concurrent applications), R (statistics), Recursion
Mathematical (symbolic math), ML, J and
K (financial analysis), and domain-specific Iteration (looping) in functional languages
programming languages like XSLT.The is usually accomplished via recursion.
lambda calculus provides the model for Recursive functions invoke themselves,
functional programming. Modern allowing an operation to be performed
functional languages can be viewed as over and over. Recursion may require
embellishments to the lambda calculus. maintaining a stack, but tail recursion can
be recognized and optimized by a
Higher-order functions compiler into the same code used to
implement iteration in imperative
Functions are higher-order when they can languages. The Scheme programming
take other functions as arguments, and language standard requires
return them as results. (The derivative and implementations to recognize and
ant derivative in calculus are examples of optimize tail recursion.
this.) Higher-order functions are closely
related to first-class functions, in those 2.3 Generic Programming
higher-order functions and first-class
functions both allow functions as Generic programming is a programming
arguments and results of other functions. paradigm for developing efficient,
The distinction between the two is subtle: reusable software libraries. The Generic
"higher-order" describes a mathematical Programming process focuses on finding
concept of functions that operate on other commonality among similar
functions, while "first-class" is a computer implementations of the same algorithm,
science term that describes programming then providing suitable abstractions so that
language entities that have no restriction a single, generic algorithm can cover many
on their use. concrete implementations. This process,
called lifting, is repeated until the generic
Pure functions algorithm has reached a suitable level of
abstraction, where it provides maximal
Purely functional programs have no side reusability while still yielding efficient,
effects. This makes it easier to reason concrete implementations. The
about their behavior. However, almost no abstractions themselves are expressed as
programmers bother to write purely requirements on the parameters to the
functional programs, since, by definition, a generic algorithm.
program with no side effects (one that Once many algorithms within a given
accepts no input, produces no output, and problem domain have been lifted, we start
interfaces with no external devices) is to see patterns among the requirements. It
formally equivalent to a program that does is common for the same set of
requirements to be required by several node, there exists a set of child nodes
different algorithms. When this occurs, corresponding to the sub-goals in the body
each set of requirements is bundled into a of the clause. These child nodes are
concept. Concepts describe a set of grouped together by an "and". The
abstractions, each of which meets all of alternative sets of children corresponding
the requirements of a concept. When the to alternative ways of solving the node are
Generic Programming process is carefully grouped together by an "or".
followed, the concepts that emerge tend to Abdicative logic programming
describe the abstractions within the
problem domain in some logical way. A Abdicative Logic Programming is an
study of graph algorithms will produce extension of normal Logic Programming
Graph concepts that describe the behavior that allows some predicates, declared as
of graphs, whereas a study of linear abducible predicates, to be incompletely
algebra algorithms will produce Matrix defined. Problem solving is achieved by
and Vector concepts. Thus, the output of deriving hypotheses expressed in terms of
the Generic Programming process is not the abducible predicates as solutions of
just a generic, reusable implementation, problems to be solved. These
but a better understanding of the problem problems can be either observations that
domain. need to be explained (as in classical
2.4 Logic programming abductive reasoning) or goals to be
achieved (as in normal logic
logic programming is, in its broadest programming). It has been used to solve
sense, the use of mathematical logic for problems in Diagnosis, Planning, Natural
computer programming. In this view of Language and Machine Learning. It has
logic programming, logic is used as a also been used to interpret Negation as
purely declarative representation language, Failure as a form of abductive reasoning.
and a theorem-prover or model-generator
is used as the problem-solver. The Higher-order logic programming
problem-solving task is split between the
programmers, who is responsible only for Several researchers have extended logic
ensuring the truth of programs expressed programming with higher-order
in logical form, and the theorem-prover or programming features derived from
model-generator, which is responsible for higher-order logic, such as predicate
solving problems efficiently.However, variables. Such languages include the
logic programming, in the narrower sense Prolog extensions HiLog and λProlog
in which it is more commonly understood,
is the use of logic as both a declarative and 2.5 Object-oriented programming
procedural representation language.
In the simplified, propositional case in Object-oriented programming (OOP) is a
which a logic program and a top-level programming paradigm that uses "objects"
atomic goal contain no variables, and their interactions to design
backward reasoning determines an and-or applications and computer programs. It is
tree, which constitutes the search space for based on several techniques, including
solving the goal. The top-level goal is the encapsulation, modularity, polymorphism,
root of the tree. Given any node in the tree and inheritance. It was not commonly used
and any clause whose head matches the in mainstream software application
development until the early 1990s. Many programmer familiar with the problem
modern programming languages now domain, meaning that the characteristics of
support OOP. the class should make sense in context.
Also, the code for a class should be
The Simula programming language was relatively self-contained (generally using
the first to introduce the concepts encapsulation). Collectively, the properties
underlying object-oriented programming and methods defined by a class are called
(objects, classes, subclasses, virtual members.
methods, coroutines, garbage collection, Object: A particular instance of a class.
and discrete event simulation) as a The set of values of the attributes of a
superset of Algol. Simula was used for particular
physical modeling, such as models to Object is called its state. The object
study and improve the movement of ships consists of state and the behaviors that's
and their content through cargo ports. defined in the object's class.
Smalltalk was the first programming Message passing :“The process by which
language to be called "object- an object sends data to another object or
oriented".Object-oriented programming asks the other object to invoke a method.”
may be seen as a collection of cooperating On Java code level message passing
objects, as opposed to a traditional view in corresponds to "method calling".
which a program may be seen as a group Inheritance: ‘Subclasses’ are more
of tasks to the computer ("subroutines"). specialized versions of a class, which
In OOP, each object is capable of inherit attributes and behaviors from their
receiving messages, processing data, and parent classes, and can introduce their
sending messages to other objects. Each own.
object can be viewed as an independent Multiple inheritances is inheritance from
little machine with a distinct role or more than one ancestor class, neither of
responsibility. The actions or "operators" these ancestors being an ancestor of the
on the objects are closely associated with other.
the object. For example, in OOP, the data Encapsulation: Encapsulation conceals
structures tend to carry their own operators the functional details of a class from
around with them (or at least "inherit" objects that send messages to it. Members
them from a similar object or "class"). The are often specified as public, protected or
traditional approach tends to view and private, determining whether they are
consider data and behavior separately. available to all classes, sub-classes or only
the defining class. Some languages go
Fundamental concepts further: Java uses the default access
modifier to restrict access also to classes in
Class: A class defines the abstract the same package, C# and VB.NET
characteristics of a thing (object), reserve some members to classes in the
including the thing's characteristics (its same assembly using keywords internal
attributes, fields or properties) and the (C#) or Friend (VB.NET), and Eiffel and
thing's behaviors (the things it can do, or C++ allows one to specify which classes
methods, operations or features). Classes may access any member.
provide modularity and structure in an Abstraction: Abstraction is simplifying
object-oriented computer program. A class complex reality by modelling classes
should typically be recognizable to a non- appropriate to the problem, and working at
the most appropriate level of inheritance Multiple-use
for a given aspect of the problem. Non-context-specific
Polymorphism: Polymorphism allows you Composable
to treat derived class members just like Encapsulated
their parent class' members. More i.e., non-investigable through its
precisely, Polymorphism in object- interfaces
oriented programming is the ability of A unit of independent deployment
objects belonging to different data types to and versioning
respond to method calls of methods of the
same name, each one according to an 3. Language Oriented Programming:
appropriate type-specific behavior. The Next Programming Paradigm

2.6 Service-orientation It is time to begin the next technology


revolution in software development, and
Service-orientation is a design paradigm the shape of this revolution is becoming
that specifies the creation of automation more and clearer. It is not yet fully
logic in the form of services. It is applied formed, different parts have different
as a strategic goal in developing a service- names: Intentional programming, MDA,
oriented architecture (SOA). Like other generative programming, etc.
design paradigms, service-orientation Programmers today have very restricted
provides a means of achieving a separation freedom. Programmers are restricted
of concerns. It is commonly acknowledged because they are heavily dependent on
that several service-orientation principles programming infrastructure which they
have their roots in the object-oriented cannot easily change, namely the
design paradigm. Some have claimed that languages and environments that they use.
service-orientation will ultimately replace The way to gain freedom
object-orientation as the de facto design is to reduce our level of dependency. For
paradigm, while others state that the two example, one of the main goals of Java is
are complementary paradigms and that to reduce dependency on the operating
there will always be a need for both. system, giving developers the freedom to
deploy on different operating systems. So,
Services inherit a number of features of to gain freedom over languages and
software components, including: environments, we should reduce our
dependency on them. Alternatively, we
could use domain-specific languages abstractions, which is difficult, not very
(DSL’s), which are tailored to be highly creative, and more or less a waste of
productive in a specific problem domain, time.
such as SQL for writing database A program in LOP is not a set of
queries. The strength of DSL’s, domain instructions. Language Oriented
specificity, is also their weakness, since Programming will not just be writing
any real-world program will involve programs, but also creating the
many different domains. languages in which to write our
In mainstream programming, most of the programs. Our programs will be written
time spent “programming” is really just closer to the problem domain instead of
finding ways to express natural language in the computer’s set-of-instructions
concepts in terms of programming level
domain, and so they will be much easier forms of documentation to capture the
to write. design and model information. This has
In LOP, a language is defined by three proven to be quite a weak solution for a
main things: Structure, editor, and number of reasons, not the least of which
semantics. Its structure defines its is the cost of writing such auxiliary
abstract syntax, what concepts are documentation, and the tendency of
supported and how they can be arranged. documentation to grow out-of-synch
Its editor defines its concrete syntax, with code. Additionally, and not as
how it should be rendered and edited. Its frequently recognized, is the fact that
semantics define its behavior, how it documentation cannot be directly
should be interpreted and/or how it connected to the concept it is
should be transformed into executable documenting. Comments are tied to the
code. Of course, languages can also have source code in a single location, but the
other aspects, such as constraints and concept may be represented in the code
type systems.The idea of LOP is to make in many places. Other types of
it easy to create special domain-specific documentation are entirely separated
languages, and those DSL’s will make from the code and can only indirectly
writing our programs easier. Language reference the code. Ideally, the code
Oriented Programming can drastically should be self-documenting. I should
improve software development. read the code itself to understand the
code, not some comments or external
LanguageOrientedProgramming: The documentation.
Next Programming Paradigm
Domain Learning Curve
Understanding and Maintaining Existing
Code
The third major problem is with domain-
The next problem we have is in specific extensions to the language. For
understanding and maintaining existing example, in OOP the primary method of
code. Whether it is written by another extending the language is with class
programmer or by us, the problem is the libraries. The problem is that libraries
same. Because general-purpose are not expressed in terms of domain
languages require me to translate high- concepts, but in lower-level general-
level domain concepts into low-level purpose abstractions such as classes and
programming features, most of the big methods. So, the libraries rarely
picture is lost in the resulting program. represent the domain directly. They must
When I come back to the program later, introduce extra complications (such as
I have to reverse engineer the program to the runtime behavior of a class) to
understand what I originally intended, complete the mapping. Two good and
and what the model in my head was. common examples are graphical user
Basically, I must mentally reconstruct interface libraries and database libraries.
the information that was lost in the
original translation to the general- Learning such libraries is not a simple
purpose programming language. task, even if you are an expert in the
domain. Since there is no direct mapping
The traditional way to address this from domain to language, you must
problem is to write comments or other learn this mapping. This presents a steep
learning curve. Usually we attempt to
solve this problem with extensive When I have a problem to solve, I think
tutorials and documentation, but learning of the solution in my head. This solution
this takes a lot of time. As a library is represented in words, notions,
becomes more complex, it becomes concepts, thoughts, or whatever you
much more difficult to learn, and want to call them. It is a model in my
programmers lose motivation to learn it. head of how to solve the problem. I
almost never think of it as a set of
Even after learning such a complicated instructions, but instead as a set of inter-
mapping, it remains very easy to misuse related concepts that are specific to the
the library because the environment domain I m working in. For example, if
(such as compiler and editor) isn t able I m thinking in the GUI domain, I think
to help you use the library correctly. To I want this button to go here, this field
these tools, a call to a method on a GUI to go here, and this combo-box should
object is the same as a call to a method have a list of some data in it
on a DB object they are both just
method calls on objects, nothing more. It which will solve the problem. weI don t
is up to the user to remember which need to explain the solution in terms of a
classes and methods need to be invoked, programming language it could be in
and in what order, and so on. almost any form. To explain how to lay
out a GUI form, we could just draw the
And even if you are an expert in the form, for example. If this drawing has
domain and also an expert user of the enough detail, then the drawing itself
library, there is still the problem of the represents the solution. Such domain-
verbosity of programs written using the specific representations should be the
library. Relatively simple domain program. In other words, there should be
concepts require complicated gestures to a method that allows me to use this
invoke correctly. Anyone who has used representation as an actual program, not
Swing, for example, is aware of this. It just as a way of communicating with
just takes too long to write simple things, other programmers. So this leads to my
and complex things are even worse. informal definition of a program: A
program is any unambiguous solution to
What Is a Program in LOP? a problem. Or, more exactly: A program
is any precisely defined model of a
Today, ninety-nine percent of solution to some problem in some
programmers think programming means domain, expressed using domain
writing out a set of instructions for the concepts.
computer to follow. We were taught that
computers are modeled after the Turing 4. Comparison of all programming
machine, and so they think in terms paradigms
of sets of instructions. But this view of
programming is flawed. It confuses the As with all immature technologies,
means of programming with the goal. I widespread adoption of AOP is hindered
want to show you how LOP is better by a lack of tool support, and widespread
than traditional programming, but first I education. Some argue that slowing
must make something clear: A program down is appropriate due to AOP's
in LOP is not a set of instructions. So inherent ability to create unpredictable
what is a program then?
and widespread errors in a system. Conclusion
Implementation issues of some AOP
languages mean that something as The ideas underlying programming
simple as renaming a function can lead paradigm are not new, and have actually
to an aspect no longer being applied been around for more than 20 What is
leading to negative side effects. new is that these ideas have silently
Programmers need to be able to read saturated the software development
code and understand what's happening in community, and their time has finally
order to prevent errors1. While they come. With this article, we hope to
have grown accustomed to ignoring the provide a seed around which these ideas
details of method dispatch or container- can crystallize into new discussions,
supplied behaviors, many are opinions, critiques, experiments,
uncomfortable with the idea that an research, and real-life projects.
aspect can be injected later adding
behavior to their code. There are also
valid security questions that code
weaving raises.
Functional programming is very
different from imperative programming.
The most significant differences stem
from the fact that functional
programming avoids side effects, which
are used in imperative programming to
implement state and I/O. Pure functional
programming disallows side effects
completely. Disallowing side effects
provides for referential transparency,
which makes it easier to verify,
optimize, and parallelize programs, and
easier to write automated tools to
perform those tasks. Aspects emerged
out of object-oriented programming and
computational reflection. AOP
languages have functionality similar to,
but more restricted than met object
protocols. Aspects relate closely to
programming concepts like subjects,
mixins, and delegation. Using AOP
judiciously to develop your own code
can result in powerful succinct
expressiveness. Using AOP to add to
code written by someone else (especially
when you don't have the source code) is
risky.

S-ar putea să vă placă și