To What End Is Functional Programming Regaining Popularity Among Programmers?

When I began my journey in coding, one of the most challenging concepts I encountered was Object-Oriented Programming (OOP). In essence, it is a programming approach that focuses on data. Since the 1970s, OOP has been the industry standard and the most popularly used programming languages in recent years have been designed with OOP at their core.

Jon Kalb raised an interesting point in his C++ 2023 lightning lecture; it appears that in recent years, many programmers have taken to either avoiding discussion of Object-Oriented Programming (OOP) or have expressed a preference for functional or procedural programming. Does this signify a major shift in the way things have always been done? Is this the end for OOP programs? Thankfully, the answer is a resounding ‘no’.

There is a heightened recognition that there are multiple methods for software development. Although this may not be of significance to the layperson (as long as the desired result is achieved with a single click), it presents both challenges and prospects for software developers.

A programming paradigm is defined as:

Can you provide a list of steps to reach the number ten? This would provide a solution to the challenge of reaching the number ten.

It is probable that there are numerous methods to achieve the same result, however the two that initially come to mind are multiplying 2 by 5 or adding 5 twice. This is a mathematical issue and the fact that many of us would likely use the same approaches for it indicates that we have a shared way of thinking.

When discussing programming languages, the term “paradigm” is often used to refer to a collection of languages which share common assumptions. Examples of object-oriented languages include Python, JavaScript and C#, while C is procedural and LISP is functional. In other fields, the word may be used to describe a consensus on a common set of ideas, behaviours and aesthetic preferences.

If the concepts of Object-Oriented Programming (OOP) and Functional Programming (FP) are unfamiliar to you at present, there is no need to worry; we can provide an explanation. Despite the variations in syntax and logic present in programming languages, they all share a common approach to problem identification and resolution.

Learn the key distinctions between Object-Oriented and Functional Programming

Object-oriented programming (OOP) is based on the concept of an ‘object’ – an entity with both properties and behaviours (methods). Modifications to attributes can be made using the methods, but objects should be self-contained so that they cannot be altered externally in an unexpected manner.

For the purpose of this argument, let’s consider a cake. Size, form, flavour and appearance are all attributes, while decorating techniques are approaches (such as eating it, giving it away, or putting candles on it). There is much more complexity involved, such as classes and inheritance, but for the sake of simplicity, let’s keep our cake example as is.

It is essential to bear in mind that data can be subject to alteration at any time when working with Object-Oriented Programming (OOP). Each piece of information can be considered a distinct entity which may transform when it is processed, similar to a cake. For instance, in a bakery, each cake is a unique object, and when one is purchased, the slice method can be used to modify the cake’s data without influencing any other cakes, tables, or cups of coffee.

In functional programming, the emphasis is more on the functions than the data, as opposed to object-oriented programming which focuses on the data itself. In other words, the emphasis is on the potential applications of the information.

It is important to consider the approach for portioning the cake, rather than the cake itself. The type of cake is of no importance, as long as the given input is suitable. The method will then produce the desired result.

Data in functional programming is immutable, meaning that it cannot be modified. When a number is used in an equation, the same answer is always produced, just like in arithmetic. This applies to any number, regardless of the type of object or entity it is associated with, such as two fruits, cakes, or cars. It is essential to remember that the number itself remains unchanged, regardless of the outcome of the equation.

The question then becomes, “Why is functional programming making a comeback?”

As computers became more widely accessible in the 1960s, the problems they could solve were relatively simple. As the computing power increased, the complexity of the problems also increased, and the amount of code needed to solve them increased accordingly. While it was easy to scan a thousand lines of code for a mistake, scanning a million lines for a missing comma was a much more difficult task.

Object-Oriented Programming (OOP) enabled us to address this issue. By structuring our code into components based on data types and the operations performed on them, it becomes more straightforward to identify the section handling cakes if, for example, a user’s slice is not correct.

Therefore, Object-Oriented Programming (OOP) offered a suitable solution to the challenges faced at the time. Over time, it became the accepted standard for how programmers should structure their work. However, as is the case with any set of rules, when applied universally, its limitations may become apparent.

Object-Oriented Programming (OOP) involves abstract thinking. For example, to add two twos using OOP, one would need to create a class called ‘Number’, with an instance of ‘2’, and a function to add it twice.

Ilya Suzdalnitski has suggested that object-oriented programming (OOP) conflicts with our natural inclinations as humans. He argues that we tend to perceive the world in terms of actions: for example, if one wishes to be hungry, they eat; if one wishes to be healthy, they go for a walk. As a result, we have a better understanding of issue representation strategies used in functional programming.

As programmes have become more complex, critics have argued that it has become increasingly difficult to maintain a readable and maintainable codebase, particularly for projects with a long lifespan. The likelihood of issues occurring increases dramatically as additional classes are added and modifications are made to their methods further down the line.

Functional programming, in contrast to Object-Oriented Programming’s dynamic behaviour, aims to create stability. If an operation is required, a function is created in order to execute it and remains unchanged until it is needed again. As long as the correct information is supplied, the results are consistent and reliable.

It is generally accepted that the Functional Programming paradigm imposes additional requirements on developers. However, there are situations in which such restrictions are beneficial; as Suzdalnitsk aptly articulated, they can limit the potential damage caused by a deficient coder.

By decoupling data from its associated functions, we can potentially make the system more stable and reduce the burden of management in the long run. In other words, data should remain data and functions should remain functions, with interaction only occurring when necessary.

An increasing number of developers are finding that functional programming is more intuitive to them than object-oriented programming, and that various problems can be better solved by utilizing different paradigms.

Is there going to be a winner?

No, not at all! The more options you have, other than an irritating project manager who believes their approach is the only valid one, the better. From my experience, most programmers tend to use a combination of object-oriented programming and functional techniques (which is not ideal, but not uncommon).

Identifying personnel who align with their chosen approach, or creating multi-paradigmatic teams that can effectively respond to the specifics of a situation, is now a key challenge facing software development organisations as functional programming (and procedural too) continues to become more widely adopted.

Despite not agreeing with the doomsayers who predict the death of Object-Oriented Programming (OOP), it is still important to consider the criticisms of it. As professionals, it is beneficial to be prepared for a world in which our coding standards and methods may be questioned.

Join the Top 1% of Remote Developers and Designers

Works connects the top 1% of remote developers and designers with the leading brands and startups around the world. We focus on sophisticated, challenging tier-one projects which require highly skilled talent and problem solvers.
seasoned project manager reviewing remote software engineer's progress on software development project, hired from Works blog.join_marketplace.your_wayexperienced remote UI / UX designer working remotely at home while working on UI / UX & product design projects on Works blog.join_marketplace.freelance_jobs