HACKER Q&A
📣 rhlsthrm

Should I learn functional programming?


I'm a full-stack web dev (skewed toward backend), fully focused on Typescript for the past couple of years. I have a pretty solid understanding of OO concepts now, and I've started dabbling in things like Domain-Driven Design, which are (from my understanding), solid extensions of OO. I've fairly recently come across more and more stuff about functional programming and various languages like Scala, Clojure, PureScript, Elixir etc. People seem to have a generally favorable opinion about these. Especially it seems like Elixir/Elm/Erlang (are these all part of the same ecosystem?) have a lot of raving fans.

My question is, what would I get out of learning functional programming? Is there a good tool or language I can learn that will make me immediatly able to apply my learnings to my daily work in backend/frontend web dev?


  👤 olodus Accepted Answer ✓
Functional programming is as much a set of design guidelines as it is a programming paradigm. As such, programming in a "functional style" can be done in almost all kinds of languages (nowadays most languages support the map, reduce and filter functions for example). So if you learn functional programming it will definitely be applicable in your day to day programming. If nothing else by giving you one more tool in your toolbelt / some new ways of thinking when tackling a new problem.

If you are interested in Erlang that is a good language to start with. Besides functional programming it also has several good lessons to teach about Distributed systems and fault tolerant programs. Some even call Erlang the only real OO language (maybe besides Smalltalk) so maybe it will make you think a bit differently about what you already know from OO (I know it did for me).

If you were thinking of starting here I can recommend the excellent "Learn some Erlang for great good" which you can read online for free. Google it.

Erlang and Elixir is not the same thing as Elm. Erlang and Elixir are separate languages but are run in the same VM (which is named BEAM) and are therefore usually named together. Elm is a language that compiles to Javascript and is used to create frontend apps for the Web.

Otherwise I have somewhat of a soft spot for clojure myself. It was one of my first foray into functional programming myself and teaching me about func prog at the same time as showing me the elegance of a Lisp will always make it have a special place in my mind. But that is only my personal opinion. If you had been interested in Erlang already you should probably go with that :)


👤 bobbyz
I've been working on an Elixir project with Phoenix Liveview for a day and a half and sadly Elixir and the surrounding ecosystem seems to suffer from a classic problem: the docs suck. If it takes me almost one day to figure out how to handle a POST request properly from GCP then that really cancels out the massive concurrency benefits or whatever I will supposedly get down the road. It doesn't matter if its Vibranium, if the docs are not enough to make it work then it's useless.