Fox explains: Programming Paradigms

Fox: Hello reader, I  forgot to tell you last time ,but I’m Glitch Fox, or more like Glitch and Fox. 1 person, two homonyms, two personalities. Glitch being the more street smart, while me, Fox  being the more book smart one. In the future posts you’ll find Glitch and me constantly struggling with, and complimenting each other. 

Now, let’s start the topic that I’m going to explain today, What is a Paradigm?

According to ‘The Merriam-Webster’s Collegiate dictionary‘,

A paradigm is a philosophical and theoretical framework of a scientific school or discipline within which theories, laws, and generalizations and the experiments performed in support of them are formulated.

Glitch: Essentially, it’s a school of thought used in solving a particular problem.

Fox:  Quite brief, Glitch. Since the formation of the first machine language, the  Binary code, all languages have classified as belonging to a particular school of thought or the hybrid of some schools of thought.

The philosophies lying behind the schools of thought aren’t exactly necessary for learning a particular language, but the people who follow the philosophies while coding in the language are usually better at learning the language as a whole.

Noob-Kun: So, since paradigms are only schools of thought, there must be a lot of them, right? What all types are there?

Fox:  Yes, and No. There are different types of programming paradigms ,however, there aren’t that many till date. In fact, you can classify most of the languages into 4 basic programming paradigms or their hybrids. These are:

  1. Imperative Paradigm:

Glitch: The main ideology behind it is:

 First to do this and next,  do that.

Fox: Or to be more precise, it has the following characteristics1:

characteristics:
· Discipline and idea
     Digital hardware technology and the ideas of Von Neumann
· Incremental change of the program state as a function of time.
· Execution of computational steps in an order governed by control structures
        We call the steps for commands
· Straightforward abstractions of the way a traditional Von Neumann computer
  works
· Similar to descriptions of everyday routines, such as food recipes and car 
  repair
· Typical commands offered by imperative languages
       Assignment, IO, procedure calls
· Language representatives
       Fortran, Algol, Pascal, Basic, C
· The natural abstraction is the procedure
      Abstracts one or more actions to a procedure, which can be called as a
      single command.
     "Procedural programming"

 

2. Functional Paradigm

Glitch: The main ideology behind it is:

Evaluate an expression and use the resulting value for something

Fox: Functional programming is in many respects a simpler and cleaner programming paradigm than the imperative one. The reason is that the paradigm originates from a purely mathematical discipline: the theory of functions 1:

Characteristics:
• Discipline and idea
    Mathematics and the theory of functions
• The values produced are non-mutable
    Impossible to change any constituent of a composite value
• As a remedy, it is possible to make a revised copy of composite value
• A temporal
   Abstracts a single expression to a function which can be evaluated as an
   expression
• Functions are first class values
    Functions are full-fledged data just like numbers, lists, ...
• Fits well with computations driven by needs
    Opens a new world of possibilities

3. Logic Paradigm

Glitch: The main ideology behind it is:

Answer a question via search for a solution

Fox: The logic paradigm is dramatically different from the other three main programming paradigms.The logic paradigm fits extremely well when applied in problem domains that deal with the extraction of knowledge from basic facts and relations. The logical paradigm seems less natural in the more general areas of computation  1:

Characteristics:
• Discipline and idea
• Automatic proofs within artificial intelligence
   Based on axioms, inference rules, and queries.
• Program execution becomes a systematic search in a set of facts, making use of a
set of inference rules

4. Object-Oriented Paradigm

Glitch: The main ideology behind it is:

Send messages between objects to simulate the temporal evolution of a set of real world phenomena

Fox: The object-oriented paradigm has gained great popularity in the recent decade. The primary and most direct reason is undoubtedly the strong support of encapsulation and the logical grouping of program aspects. These properties are very important when programs become larger and larger.

The underlying, and somewhat deeper reason to the success of the object-oriented paradigm is probably the conceptual anchoring of the paradigm. An object-oriented program is constructed with the outset in concepts, which are important in the problem domain of interest. In that way, all the necessary technicalities of programming come in second row 1:

Characteristics:
• Discipline and idea
  The theory of concepts, and models of human interaction with real world
  phenomena
• Data as well as operations are encapsulated in objects
• Information hiding is used to protect internal properties of an object
• Objects interact by means of message passing
   A metaphor for applying an operation on an object
• In most object-oriented languages objects are grouped in classes
    Objects in classes are similar enough to allow programming of the classes,
    as opposed to programming of the individual objects
    Classes represent concepts whereas objects represent phenomena
• Classes are organized in inheritance hierarchies
    Provides for class extension or specialization

 

Noob-Kun:  So are these all there is t programming paradigm? Can all languages be classified using only these paradigms?

Fox:  The world of programming is vast and never-ending like the Universe, or the Internet. Thus, the paradigms of programming can’t all be classified under these 4 basic schools of thought,  however, it’s through them that we developed various other languages , and these paradigms won’t ever be forgotten as the basics of programming.

Some other noteworthy paradigms include:  Constraint-based paradigm, Visual paradigm, and parallel paradigms.

While I’d like to talk about this topic in the future as well, as a book can’t be fit into a page, please keep patience, and scrutinize…


  1. Content taken from pdf file paradigm.pdf 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s