The major Programming Paradigm in today's programming world is Object Oriented Programming. In this a Program consists of Objects. One writes a Class and when the Class is instantiated it results in an Object. The class is the Abstraction of Objects that will exist in the Program.
Objects have Attributes which can be set to represent different concrete Objects.
Objects have Methods which can be invoked to change the status of the Object or to make the Object do something.
E.g.
class Person {
/* Attributes */
String name;
int age;
char gender;
/* Methods */
talkTo(Person);
becomeFriendWith(Person);
}
is a class. It is a definition of the class Person. This can be used to represent different people with different attributes.
E.g.
MsJane = new Person();
MrJohn = new Person();
Person.name = "Ms. Jane";
Person.age = "52";
Person.gender = "F";
Person.name = "Mr. John";
Person.age = "25";
Person.gender = "M";
MsJane.talkTo(MrJohn);
MsJane.becomeFriendWith(MrJohn);
In the above example MsJane and MrJohn are instances of the class Person. They are "Objects" that will come into being when somebody runs the programs and they will die once he Program stops.
The Class Person continues to exist.
Most common Object Oriented Programming Languages are:
- C++
- Java
- SmallTalk
Procedure Programming is a paradigm where programs contains Procedures. Procedures are pieces of code which does some work. The Program itself is a series of invocation of Procedures.
The Procedure itself is a set of instructions telling the computer what to do. See (http://en.wikipedia.org/wiki/Procedural_programming).
Procedures are also called as Subroutines or Functions.
Most common Procedural Programming Languages are:
- C
- BASIC
- COBOL
Functional Programming as the name indicates consists of a set of Functions that does something. This may be easily confused with Procedural Programming as the code pieces are also called functions. But there are major differences between Functional Programming and Procedural Programming, the main ones being
1. Variables can be assigned different values in Procedural Programming. In Functional Programming a variable is assigned a value only at the time of declaration. The value of the variable never changes.
2. Global variables are common in the Procedural Programming Paradigm. There are no global variables in Functional Programming Paradigm.
3. There are no Lambda functions in Procedural Programming Paradigm. Functional Programming Paradigm is all about Pure Functions. Functions can be passed around and that is the Key, "Passing Functions around" as if they were variables.
4. Procedural Programming is all about manipulating variables and creating side effects. Functional Programming Paradigm entails no Side Effects.
Most common Functional Programming Languages are:
- Lisp
- Scala
- F#
This is basically a Paradigm where solutions to problems are determined. It is used in Mathematical programming and it applies different rules to arrive at a solution.
Most common Logical Programming Languages are:
- Prolog
No comments:
Post a Comment