functional programming

What is functional programming why it matters for your business?

functional programming

Since functional programming evolved from lambda calculus and has its roots in academia, it was initially discussed in scholarly contexts. It’s no longer the case. Even though significant technologies associated with functional programming (such as Lisp or Scala) were created at universities — FP is making its way to the general “software development discourse,” and some might say that it’s taking it by storm. 

Despite the rising interest, however, not many articles on the web seem to tackle the benefits of functional programming for business. Let’s face it: hacking a new technology in spare time is great, but there’s always a practical side to business when it comes to trying out new things and having a good reason for that. And that’s precisely what we’re about to cover in this piece. 

Here’s what functional programming is, and why does it matter for your business. 

What is functional programming in the first place?

Functional programming (FP) is a programming paradigm, a certain way of thinking about software development that’s based on a few defining principles. In the case of FP, these key principles are as follows:

  1. Binding everything in pure mathematical functions. The purpose is to look for simple, repeatable actions that can be abstracted out into a function and then built upon to create more complex features.
  2. Immutable, unchangeable data — which means that you should rather create new data structures, not altering the ones that are already in place. For example, if you want to modify data in an array, you need to add a new array with the updated value instead of making changes to the “original” one. 
  3. Declarative code. The main focus here is on what to solve, rather than how to do it. 
  4. Statelessness. Functional programs should perform each and every task as it was for the very first time, without any knowledge of what happened (or not) earlier in their execution. 
  5. Recursion. There is no “for” or “while” loop in functional languages, iteration is implemented through recursion. Basically, recursive functions repeatedly call themselves, until the base case is reached. 

Functional programming vs OOP (Object Oriented Programming)

Speaking of programming paradigms, you might already be familiar with another one that’s still more popular: object-oriented programming (OOP). This doesn’t mean, however, that FP is not gaining any traction. Both functional programming and object-oriented programming are unique in their own ways. 

Here’s functional programming vs OOP at a glance to help you grasp the differences:

XFunctional programmingObject-oriented programming
Programming modelDeclarative Imperative
FocusWhat you’re doingHow you’re doing
Parallel programmingSupports parallel programmingNot suitable for parallel programming
Side effectsIts functions have no side effectsIts methods can produce side effects 
IterationRecursion“Loop” concept
Application stateFlows through pure functionsIs usually shared and colocated with methods in objects 
Key elements of the codeVariables and functions are the main elements of the codeObjects and methods are the key elements

What about programming languages, then?  

Pure functional programming languages, such as Haskell, are specially designed to serve this particular paradigm and accept only pure functions. Interestingly, you don’t need to use a pure functional programming language to bring FP principles to your code. 

There are a few languages that still make it easy to write “pure programs”, such as Scala, Clojure or OCaml.  More popular programming languages like JavaScript or Python can also support FP one way or the other – either natively or with the right library.

At Scalac, we’re big advocates of functional programming and, which shouldn’t come as a surprise, we mainly use Scala for this purpose.  There are at least a few good reasons for that:

  • The language is extremely versatile and offers advanced features, clean code, and both functional and object-oriented programming in an open-source, practical package that leverages Java’s environment. 
  • Speaking of — Scala has emerged as one of the most powerful Java alternatives. Actually, one of the reasons why Scala was created in the first place was to address various concerns developers had with Java. Nowadays, Scala provides interoperability and compatibility with Java, allowing the developers to keep their Java libraries, and leverage the advantages of JVM. 
  • When comparing it to Python, on the other hand, Scala’s maintenance is simply much faster. Despite providing the fluency and flexibility of a dynamic language like Python, it’s still a strongly statically typed language. The performance also tends to be much more efficient, especially in a multi-threaded environment.  
  • Because of its functional aspects and flexibility, Scala is also useful for expressive code and parallelism. Basically, with a functional approach and no mutation, there are no race conditions and parallelism gets a lot more straightforward. Then, lambda expressions are also helpful when communicating some aspects of parallelism. 

But, the question remains:

Why should you use functional programming (and Scala, for that matter)?

For some reason, this programming paradigm still seems complex for many. When taking a closer look at the benefits of functional programming and the languages associated with it, you might have a different impression. 

To start with, adopting functional programming helps you break down every application into smaller, simpler pieces that are both more reliable and easier to understand. It’s mostly because functional code tends to be more concise, predictable, and easier to test. How come? 

  • Since pure functions don’t change any states and depend only on the input given, they are much easier to grasp
  • When there’s less code, there are also fewer bugs — not to mention that actual testing and debugging gets much easier with immutable data and pure functions that take only arguments and produce output. 
  • With the outputs depending only on the arguments passed to the function, the software can also behave more “predictably”
  • FP adopts Lazy Evaluation which avoids repeated evaluation (basically, the value is evaluated and stored only when it is needed) and supports other Lazy Functional Constructs like Lazy Lists, Lazy Maps, etc. 
  • Functional programming also means efficient parallel coding — there’s no mutable state and no state-change issues, which supports easy reusability and testability. 
  • Speaking of efficiency, functional programs consist of independent units that can run concurrently and can be more efficient as a result. 

Since Scala supports functional programming, these benefits apply to it as well. The combination of features in Scala makes it possible to write programs that are concise, elegant, and much easier to debug & maintain. 

As a result, increasingly more companies switch to both functional programming and Scala, including well-known tech giants like Twitter or LinkedIn. Interestingly, Scala also made it to the top 10 languages that developers want to learn these days. 

The rising interest from both companies and developers are contributing to the recent growth of functional programming and the adoption of Scala as the main language for many applications — also in a business setting. 

What do functional programming & Scala mean for your business, though?

No doubt knowing the principles of functional programming can broaden one’s horizons and introduce new ways of thinking about software development. But what’s in it for the companies? 

To start with, code quality. When it comes to functional programming — very often, you can do more with less code. It’s much more concise, which essentially means fewer bugs, and a shorter time (and/or fewer people) to actually write it. Plus, it’s a lot easier to grasp what the code does, explain it, and even onboard new team members who can almost immediately join the project and start working on it. In the process, Time to Market often gets shorter. 

What’s also worth mentioning is that the interest in functional programming and languages that bring its principles to life stems from being tired of limitations posed by other programming paradigms and technologies. As already mentioned, Scala as a modern language has plenty of useful features that you won’t find in Python and Java. Even implementing it can be a big savings cost of the bottom line. 

What’s more, there are already some business cases that both functional programming and Scala have been applied to successfully. Health care, accounting, banking, advertising — are just a few exemplary industries.

For the time being, functional programming seems to work best with apps aimed at concurrency or parallelism, carrying out mathematical computation, and whenever there are many different operations performed on the same data set. Scala is a good fit if you have a lot of data or complex data structures and algorithms, but FP languages are also often used for artificial intelligence applications like machine learning, language processing, or modeling of speech and vision. Pretty impressive, right?

With the rising interest and so many benefits of functional programming, how come it’s not yet as widespread as it should be? 

At the end of the day, businesses rather choose the technology based on the skills of their team or the availability of developers, who are more likely to represent more traditional approaches to software development. That’s precisely why it matters not only to educate developers about FP but also to give them tools to apply it in practice. 

For now, “the movement” is all bottom-up: it’s starting from developers who are tired of being limited by other programming languages, become interested in functional programming, and then teach their colleagues about it. 

As these developers start creating libraries and frameworks that solve specific business problems across multiple areas (such as backend development, analytics, distributed development) with the use of functional programming — eventually decision-makers will also get excited about FP. And, the more companies are interested in functional programming, the more developers skilled at it they want to hire. It’s a chain reaction from there. 

To facilitate the shift to functional programming, drop some of the jargon around FP and lower the barriers to entry, there are initiatives and projects like ZIO — a library for asynchronous and concurrent programming based on pure functional programming. Taking advantage of it is said to help in solving common business problems, and ensuring higher success rates of projects. This, in turn, brings more attention to functional programming, in the business world as well. 

What’s also great about ZIO is that it’s inclusive for all sorts of developers. It’s still fairly new, but it’s expected to be a great venture in the long run, mostly due to all the open-source support it gets. It might be difficult to take advantage of ZIO when developing enterprise-level software just yet, but more and more companies are already testing it in production for smaller projects. And that’s only one of the reasons why the future of functional programming is definitely bright. 

Dig into functional programming yourself 

Increasingly more companies are prepared to train development teams on how to use FP and solve business problems with functional programming, including Scalac

Switching to functional programming can be done whenever there’s a new module to implement and thus, can be done gradually. Start small, and see how big of a difference the main aspects of functional programming can make to your business. As per usual, we’re here to help

Read more:

Download e-book:

Scalac Case Study Book

Download now


Łukasz Kuczera

I wrote the first computer program when I was 8 and founded the first company when I was 16. Since then, I'm looking for opportunities to improve the world around me. I'm a peoples person, and I love to lead and inspire. I couldn't find a "company that I always wanted to work for," so I decided to create my workplace where I can share my passion with likeminded individuals. I have been wearing different hats throughout my career and founded several projects and companies. I worked as a System Administrator, Software Engineer, and Architect I held the role of VP of Engineering and CEO. I founded ISP company, gamification startup, Venture Fund, Gamedev studio, and specialized software development company.

Latest Blogposts

17.04.2024 / By  Michał Szajkowski

Mocking Libraries can be your doom

Test Automations

Test automation is great. Nowadays, it’s become a crucial part of basically any software development process. And at the unit test level it is often a necessity to mimic a foreign service or other dependencies you want to isolate from. So in such a case, using a mock library should be an obvious choice that […]

04.04.2024 / By  Aleksander Rainko

Scala 3 Data Transformation Library: ducktape 0.2.0.

Scala 3 Data Transformation Library: Ducktape 2.0

Introduction: Is ducktape still all duct tape under the hood? Or, why are macros so cool that I’m basically rewriting it for the third time? Before I go off talking about the insides of the library, let’s first touch base on what ducktape actually is, its Github page describes it as this: Automatic and customizable […]

28.03.2024 / By  Matylda Kamińska

Scalendar April 2024

scala conferences april 2024

Event-driven Newsletter Another month full of packed events, not only around Scala conferences in April 2024 but also Frontend Development, and Software Architecture—all set to give you a treasure trove of learning and networking opportunities. There’re online and real-world events that you can join in order to meet colleagues and experts from all over the […]

software product development

Need a successful project?

Estimate project