We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies.

We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies. Less

We use cookies and other tracking technologies... More

Login or register
to apply for this job!

Login or register
to save this job!

Login or register to start contributing with an article!

Login or register
to see more jobs from this company!

Login or register
to boost this post!

Show some love to the author of this blog by giving their post some rocket fuel 🚀.

Login or register to search for your ideal job!

Login or register to start working on this issue!

Engineers who find a new job through Blockchain Works average a 15% increase in salary 🚀

Blog hero image

Why You Should Learn Functional Programming

Marty Stumpf 13 January, 2021 | 3 min read

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!

Author's avatar
Marty Stumpf
Dev @metastatedev making @juvixlang in Haskell. Loves FP Coq Agda PLT. Always learning. Prior: Economist. Vegan, WOC in solidarity with POC.
    OCaml
    Standard ML
    Matlab
    Octave
    Haskell
    Idris
    Smart Contracts
    Blockchain
    Data Analysis

Related Issues

WorksHub / client
  • Started
  • 0
  • 17
  • Intermediate
  • Clojure
  • $150
viebel / klipse-clj
viebel / klipse-clj
  • Open
  • 0
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • Open
  • 0
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • 1
  • 0
  • Intermediate
  • Clojure
viebel / klipse
  • Started
  • 0
  • 2
  • Intermediate
  • Clojure
  • $80
viebel / klipse
  • Open
  • 0
  • 0
  • Advanced
  • Clojure
  • $80
viebel / klipse
  • Started
  • 0
  • 2
  • Advanced
  • Clojure
  • $180
viebel / klipse
  • Started
  • 0
  • 1
  • Intermediate
  • Clojure
viebel / klipse
  • 1
  • 1
  • Advanced
  • Clojure
  • $300

Get hired!

Sign up now and apply for roles at companies that interest you.

Engineers who find a new job through Blockchain Works average a 15% increase in salary.

Start with GitHubStart with Stack OverflowStart with Email