Functional, Procedural, and Object-Oriented Programming
A Quick Summary Of The Differences
15 May 2015
According to C2.com, there are over 200 ways to write a simple computer program that outputs “Hello World”. Programming languages are constantly being invented to deal with new problems. Even if you are a master at one programming language, it only means that you are equipped to solve one set of problems efficently. That’s not enough in the competitive marketplace.
There are three major types of programming languages, and it is important to familiarize youreslf with them so that when it comes time for you to master a brand new language, you are ready for the task.
- Functional langauges are based on carrying out the results of mathematical functions. These languages are easy to grasp: input goes in, and output comes out. The math, on the other hand, is less easier to understand. Functional languages were the first programming languages to be invented, but have fallen into disuse as programmers tended to prefer the other two types of languages. However, some programmers have started "rediscovering" functional languages, and like the fact that they run can multiple functions at one time ("parallelism"). This means that programs can complete tasks much faster than in the other types of programming languages. An example of a functional language today is Haskell.
- Procedural langauges based themselves on procedures. A procedure tells a program exactly what it has to do, and the program happily follow those step-by-step directions. Those directions include certain "behavior" that a program is expected to perform. You are limited to the behavior that the procedural language has given you; you cannot create brand new behavior. As a result, it is easier to understand what a program is doing by looking at its source code. The most popular procedural language today is COBOL (though it does have a reputation for being "old-fashioned" compared to the newer object-oriented languages, and the "legacy programs" based on COBOL are slowly being replaced). Other procedural languages include BASIC, Pascal, Fortran, and C.
- Object-oriented languages care about objects. An object contains both data (information/attributes) and behavior (methods). You can give objects information to hold, while also telling objects to "do" certain stuff. This radical approach means that it is theoretically possible to reuse the same object in different circumstances, saving people time and resources. However, someone examining the code must be able to decipher what behavior each object is doing. As the programmer can change the behavior of objects or add new behavior,
Practical Object-Oriented Design In Ruby claimed that an application may end up developing its own "unique programming language specifically tailored to [its] domain". Unless the application is properly designed, understanding this 'unique programming language' will become a chore. Most popular languages today are object-oriented, including Ruby, Javascript, and C++.