DEV Community

Cover image for Functional Programming Asks For a Mutable Developer
Vinicius Brasil
Vinicius Brasil

Posted on

Functional Programming Asks For a Mutable Developer

The class you have been waiting for. It is your programming class in school and the professor offers you plenty of interesting and essential words: objects, classes, constructors, inheritance. You love programming! And that's programming, right? Well, that's one way of structuring your program. And a very thought-provoking way, as object-oriented programming feels quite natural to most people.

Later on, you got a job to work with Erlang, this programming language that you certainly did not learn in your classes. Erlang is a functional programming language. It's not that is better or worse than Java or C++. It's just different as it has a different paradigm. The thing is you have no classes, no constructors, no methods, no inheritance, and all the concepts you had learned as simply "programming". You try to use the same techniques you know but it just seems off.

You have to start thinking functionally. Not imperatively. Not object-oriented. This asks for a mutable mind. A mind that will have to sometimes shift between paradigms and understand fully all the differences between them. Immutability is a central concept of functional programming, but a mutable developer, that is up to change, is essential for learning a new paradigm.

Here are some tips for you to consider when learning FP:

  • Understand that a different paradigm means problems are solved differently
  • Master the concepts before jumping into libraries and frameworks. First-class functions, high-order functions, purism, recursion, immutability, type systems
  • Learn functional languages such as Erlang, F#, Clojure, Haskell to help you apply the concepts into multi-paradigm languages, such as JavaScript
  • Don't rush to learn the most complex topics as functors, monads, currying
  • Apply basic concepts to your day-to-day code gradually. Immutability and purism are two functional-thinking concepts that you can use in Ruby or JavaScript. That can make the code more testable, deterministic, and easier to read

The process to learn functional programming can be daunting and slow as new concepts are involved. It is not like learning Ruby from a Java background. It actually is like learning how to sail a boat knowing how to drive a car. It is completely normal to struggle at first, but mutate your mind to resiliency and always keep learning.

Top comments (0)