Object Oriented vs Functional

Which do you pick?

01/09/2015

As I have been diving into programming I have started to learn a lot about the different types of languages there are out there. Not only is every language unique, but each language can also fit into a higher classification (similar to a monkey being a mammal). Two opposing classifications that we have been looking into are Object-oriented vs Functional programming. I want to take a little time to break down what each one is.

Object-oriented programming, aka OOP, is a language that focuses on objects and data over actions and logic. OOP is built around classes. Within these classes we define the methods they use as well as the data they store. From classes, we create objects, or individual instances of the class. These objects interact with each other in certain ways. Because each class only defines the information that it needs, when an object is run it cannot access other programming data. The concept of classes also allows programmers to create any new data type that does not already exist in the language. Examples of popular OOP languages are Java, Python, C++, Visual Basic .NET, and (my favorite) Ruby.

Functional programming, FP, is a style of programming which models computations as the evaluation of expressions. Huh? In FP, programs are run by evaluating expressions (think back to expressions in algebra). FP languages are very useful in distributed systems. If you are writing your program in a FP language, it will do exactly what you expect every time and operates in an environment where its tasks can be shared across hundreds or thousands of networked computers. There are two unique qualities of FP. The first is data is immutable. This basically means that it does not change. The second is functional programs are stateless. Meaning they run every task as if it was the first time with no knowledge of what came before in the program. Examples of functional programming languages are Haskell, Erlang, Lisp, and D.