We're planting a tree for every job application! Click here to learn more

Why You Should Learn Functional Programming

Marty Stumpf

7 Apr 2022

3 min read

Why You Should Learn Functional Programming
  • Haskell

Many of the widely used languages (including C++, Java, and Javascript) are imperative.  In imperative programming, computations are structured as sequences of instructions that operate by making modifications to the state of the program.  Functional languages operate by declaring functions. The output value of a function depends only on the arguments that are passed to the function.  Because of this, functional languages have a few advantages that minimize mistakes.

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." --John Carmack

Until recently, functional languages were considered "academic" and for research only. But the industry has since discovered their advantages and many leaders are adopting functional programming to gain competitiveness.

In this post, I'll list a few reasons why you should learn functional programming.

It makes you a better programmer

Functional programming, especially typed functional programming, offers a very different mental toolbox than the traditional programmer usually uses. For example:

Immutability

Unlike in imperative languages, in functional languages, variables are immutable by default and do not depend on the state of the program.  Along with referential transparency (given the same inputs, a function always return the same results), this increases consistency. As a result, we have reduced errors, increased stability, and increased effectiveness of tests. For example, tools like QuickCheck are very effective.

Type safety

Modern functional languages are usually statically typed, which means that they type check (verify all functions have the correct input types passed to them and return the correct type) at compile-time as opposed to run-time.  This ensures that all programs in production are type safe.  Even though some imperative languages are also statically typed, they don't offer as many safety guarantees as modern functional languages.

Memory safety

Functional programming languages handle allocation and de-allocation for you. The compiler avoids many common memory leaks that imperative programmers see and completely removes the risk of null dereferences.

Purity

In pure functional languages like Haskell, you can prove the absence of unwanted side-effects.  Because pure functional languages operate with functions that are type safe, you can control whether a function in the code has any interaction with the outside world more easily.

And many more! See here and here for more details.

These new tools and perspectives empower you to write better programs even when you write in traditional languages. In fact, many modern extensions/frameworks have functional flavours added. See for example ReasonML and typescript. Learning functional programming will give you the necessary building blocks to pick up these frameworks quickly and correctly.

It's enjoyable

A far smaller cognitive load is required when writing functional rather than imperative code. As mentioned above, in functional programming the compiler type checks and ensures memory safety. In addition, functions have no side effects. Therefore, many concerns present in imperative languages can be completely offloaded to the compiler. With this tedious cognitive load freed up, the functional programmer can focus on the more fun part of programming: designing the implementation! When we develop in functional languages we often write much less code, in substantially less time, and with fewer bugs.

It gives you great career prospects

Many companies have adopted functional programming and there are many opportunities for functional programmers. Companies using Haskell include Facebook, Hasura, etc. Companies using OCaml include Ahrefs, Jane Street, etc.

Check out Functional Works for many more companies that are using functional languages!

Functional languages are prominent in blockchain especially. Blockchain is an increasingly popular technology with applications in many areas. The most common uses of the technology include cryptocurrencies, banking/FinTech, and smart contracts. They all involve financial transactions that are time-sensitive and mistakes can be very costly. Functional languages can minimize these mistakes and therefore many blockchain and related applications are written in functional languages! For example, Mina and Tezos are written in OCaml. Cardano, Kadena and BlockApps are written in Haskell.

Check out Blockchain Works for many more blockchain-related companies that are using functional languages!

In conclusion, functional languages have advantages over imperative languages. They are already well-used in the blockchain world and are really catching on in other areas as well. Whether you want to stay up-to-date, expand your career choices, or broaden your programming knowledge, learning functional programming is the ideal choice!

If I've got you convinced, I've got more good news for you! I'm going to publish a series of posts introducing functional programming concepts. You don't need to have a background in functional programming or even programming. I'll go through practical concepts from beginner to advanced levels with many code examples.

Stay tuned!

Did you like this article?

Marty Stumpf

Software engineer. Loves FP Haskell Coq Agda PLT. Always learning. Prior: Economist. Vegan, WOC in solidarity with POC.

See other articles by Marty

Related jobs

See all

Title

The company

  • Remote

Title

The company

  • Remote

Title

The company

  • Remote

Title

The company

  • Remote

Related articles

JavaScript Functional Style Made Simple

JavaScript Functional Style Made Simple

Daniel Boros

12 Sep 2021

JavaScript Functional Style Made Simple

JavaScript Functional Style Made Simple

Daniel Boros

12 Sep 2021

WorksHub

CareersCompaniesSitemapFunctional WorksBlockchain WorksJavaScript WorksAI WorksGolang WorksJava WorksPython WorksRemote Works
hello@works-hub.com

Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ

108 E 16th Street, New York, NY 10003

Subscribe to our newsletter

Join over 111,000 others and get access to exclusive content, job opportunities and more!

© 2024 WorksHub

Privacy PolicyDeveloped by WorksHub