Functional Programming – In a Nutshell

Object-Oriented or Functional Programming?

With the number of software developers steadily increasing every year, the expectation of the quality of software increases. This clashes with the fact that languages like Python and JavaScript are becoming more popular since those languages are infamous for their low standard of code quality. Their lack of a type system alongside the object-oriented paradigm might cause problems in the long run.

Object-oriented programming is a paradigm where the focus lies on objects that contain data and code. The data is in fields, and the code is in methods or functions. That lets the developer think of their code as entities and their relations. Since relations between objects change over time, the state of an object is essential.

I will cover the functional programming paradigm, and it completely discards the idea of objects. Its goal is to discard state and mutable data. Whenever you input something into a program, the output will always be the same. Thus, the result of a function is only reliant on its arguments. To ensure the function’s result is described only by its inputs, it cannot have any side effects.

Functional Programming compared to Object-Oriented Programming – kingslanduniversity.com

Why Functional Programming?

The main advantages of functional programming are reusability, statelessness and testability. That means the number of developers needed for a project decreases. In this answer on StackOverflow, Brian Campbell describes that using functional programming is at least as efficient as any other form of programming and thus shouldn’t be disregarded based on its efficiency. Pair this with the fact that most of the code you write will be reusable, and you can have a smaller developer team on your project.

If you can have fewer developers on a team, it can lead to greater interoperability between the developers. That means you are less likely to run into the issue of introduction overhead. That is a big problem when working with a software engineering project, where if you add more developers to a project, it will almost certainly delay the finish of it.

What is the Future of Functional Programming?

The 2020 developer survey on StackOverflow, shows that the first functional programming language is Scala in the list of most used programming languages, on the 21st spot. That indicates that functional programming is not the most popular programming paradigm. However, compared to the previous years, it has been growing slowly.

I assume the introduction of functional programming concepts in more popular programming languages, functional programming will become more popular. However, a purely functional programming language is hard to learn, even harder to master, and thus will not take over the programming world any time soon.