Programming Paradigms

An overview of three different paradigms

Posted by Nolan Hughes on December 10th, 2018

We're going to look at a few common programming paradigms in this post. A programming paradigm is a style of programming or a set of concepts or thought patterns that share a common thread. A paradigm is just a way that we as programmers do something.

Imperative Programming

In its simplest form, imperative programming can be summed up with the phrase, "First do this, next do that." This means that it consists of a list of things to do that are given to the program to execute in a specific order. It's very much like following a recipe.

Object-Oriented Programming

Object-Oriented Programming is basically data, represented as objects. Objects are instances of a class and have attributes and methods. These objects are seperate entities and their attributes (state) can be modified with predefined methods. This type of programming is great for associations. It enables you to modify data that is related to what you are operating on by way of relationships.

Functional Programming

Functional Programming avoids changing state and any mutable data. Every time a function is called with an argument of x, it will produce the same result. Its output is only concerned with the arguments that are passed to it and not the state. This helps to eliminate side effects and drastically reduce bugs. This being one of the main reasons for its popularity.

Conclusion

Each of these paradigms have their place in the programming world and have their own reasons for existing. I had an enlightening talk during a job interview last week that made me think about how in my previous career as an audio engineer I was already using some funcitonal paradigms in my workflow. This correlates directly with what I had previously thought about using stateless functional components in React aligning with my way of thinking. I didn't realize the direct connection until last week but it was awesome to put two and two together!