Search This Blog

Wednesday, July 4, 2012

Programming languages and their classifications

Welcome to my first post !!
Without any further ado....i will start narrating my experiments with learning.
I was taught about categories of programming languages today. I was aware of Object oriented programming language and I also knew that C is not an OOP language. But I didn’t know about other categories I was taught today. They were procedural and functional languages. So I came to an understanding that there are 3 main categories of programming languages namely
·      Procedural
·      Functional
·      Object Oriented
Procedural languages:
One very important thing I learnt today is that C can be categorized as procedural. Other examples of procedural languages are BASIC,PASCAL,FORTRAN. Machine language is obviously procedural. Procedural languages are those in which statements get executed sequentially. More explanation regarding this follows later in this post. Keep reading.
Functional languages:
Functional languages are those which have functions to execute to almost all steps and the steps are not necessarily linear. For example, let’s assume “Solution(X)” is a function which gives the roots of a quadratic equation X. What this function does is it calls another function to find the discriminant of the equation. After finding discriminate another function is then called to calculate the roots. In this way everything happens as functions. The functional languages are mainly used in mathematical applications. Examples are Haskell and any language based on LISP. More information about Functional languages and functions are on their way.. just keep reading.
OOPS:
I already knew basic concepts of OOPS. Data abstraction, Data encapsulation, Polymorphism and Inheritance were touched upon during the discussion. OOPS is a new programming paradigm which uses real life like entities called objects. OOPS is all about these objects interacting with each other to change the state of the program. An OOP language doesn’t always have a linear control flow. I was told that Ruby is designed to be a pure Object oriented language. Even the numbers like 1,2,3.4 etc. are objects in Ruby. But then OOP languages have borrowed concepts from procedural as well as functional languages. We will see more about OOPS, later in this post.
So that sums up the discussion session I had. Now I will tell more about what I later researched and found interesting.
More about procedural :
Procedural languages are named so for a reason. So what’s a procedure then??
A procedure is a named block of code, like a subroutine, but with some additional features. For example, it can accept parameters.
For those wondering what a subroutine is...
Generically, the term subroutine can be used to denote a piece of code, separate from the main body, fulfilling a discrete task, in language-neutral terms
In simple terms procedure is a set of instructions grouped together. For example, for washing clothes the steps are
1.   Take cloth
2.   Apply soap
3.   Rinse
4.   Soak it dry
These steps are followed every time when we wash clothes and their order cannot be changed.
Similarly in procedural languages we have steps/instructions whose order cannot be changed. If they are changed we get logical or syntactical errors. A code block can be separated and reused by calling it many times, this may mean changing the control flow but they don’t make this code block independent...still everything(data) is tightly coupled and the core of the language remains procedural. Hope you understand what I mean!!
More about functional:
Functional Languages. Why are they named so? To understand them... let’s see what a function is first.
A function is just like a procedure except that it returns a value. Traditionally, a procedure returning a value has been called a function, however, many modern languages dispense with the term procedure altogether, preferring to use the term function for all named code blocks.
Anyone who has used a spreadsheet has experience of functional programming. In a spreadsheet, one specifies the value of each cell in terms of the values of other cells. The focus is on what is to be computed, not how it should be computed.
Another well-known nearly-functional language is the standard database query language SQL. An SQL query is an expression involving projections, selections, joins etc ... The query says what relation should be computed, without saying how it should be computed. SQL implementations often perform extensive query optimization which figures out the best order in which to evaluate the expression.
I was told that Mathematica from Wolfram alpha is also functional.
The above points must make clear what a functional language is. A functional language may be easy to code with but they are not always the fastest particularly when competing with procedural languages like C.
More about OOPS:
Finally OOP languages! They are about objects where data is coupled with methods. So what are those methods? As the name suggests they are functions telling HOW to act on data. Methods are in turn procedural!
OOPS are advanced in many aspects... they are easy to code ( not for beginners ), has re-usability and high security. So one must adopt OOPS whenever possible. Trying to be object oriented in procedural languages is bad coding technique.
Few other points discussed for the day were about Frameworks. Rails is a framework for Ruby. It is to be noted here that Rails is not Object oriented like Ruby !
That pretty much sums up my learning for the day... Thanks for showing patience in reading my experiments with learning.


Trained @ Sourcebits

No comments:

Post a Comment