DEV Community

loading...

I want to learn functional programming: where to start?

Vini Brasil
I am a software engineer working with Elixir, theology student, and musician based in beautiful Curitiba.
・1 min read

Hi there!

I want to learn functional programming, and a "functional programming language" such as Elixir, Elm, Haskell, etc.

For you that are avid functional programmers, where to start?

Discussion (7)

Collapse
ben profile image
Ben Halpern

Elm strikes me as a pretty good place to dive in because it:

  • Executes in the browser, similar to other stuff you've used in JS land.
  • Is purely functional and pretty hardcore in this sense
  • Is designed to be more "mainstream" than Haskell
  • Has a friendly community

Since you come from Ruby on Rails land, Elixir might be a good choice because it's sort of an offshoot from that ecosystem and has a lot of community crossover.

This is my answer as someone who tends to start with practical use cases and work down to theoretical.

@xtrasmal is a great choice if you are more of a bottom-up learner.

Collapse
kjwong3 profile image
Kelly Wong

If you're a web dev, Elm is a great place to start. I followed the guide when I was first getting started at the beginning of last year, and having a blast with it ever since!

Collapse
xtrasmal profile image
Xander

Hi there. Language apart, I'd like to point you to this resource
Category Theory for Programmers(github.com/hmemcpy/milewski-ctfp-pdf) or buy the book, because it is very good. It talks about composition. Here is a quote from the book:

"Composition is at the very root of category theory — it’s part of the definition of the category itself. And I will argue strongly that composition is the essence of programming. We’ve been composing things forever, long before some great engineer came up with the idea of a subroutine.
Some time ago the principles of structural programming revolutionized programming because they made blocks of code composable. Then came object oriented programming, which is all about composing objects.
Functional programming is not only about composing functions and algebraic data structures — it makes concurrency composable — something that’s virtually impossible with other programming paradigms."

The book uses examples from Haskell and other languages, as illustrations. So you will learn a little of that while you are at it.

When picking a functional language like Elixir, you will find that there is more stuff than just the language that are immensely awesome to tap in to. Like Elixir runs on BEAM, it is fault-tolerant(and other cool things), it has a framework called Phoenix for frontends(for example) and there is a thing called Nerves Project, which allows you to burn your code to an image for embedded systems.

Collapse
nestedsoftware profile image
Nested Software • Edited

What programming languages do you have the most experience with?

I would start by making sure to understand these basic concepts:

  • recursion
  • pure function
  • closure
  • higher-order function

Next I would look at these well-known higher-order functions:

  • map
  • filter
  • fold (aka reduce)

These are ideas that can be used in many programming languages. In particular, if you're familiar with python or javascript, all of the above topics can be understood and applied in a natural way in both of them.

Then you could go into topics that tend to be more relevant in really pure functional languages like Haskell (functors, monads, monoids, combinators...).

Collapse
somedood profile image
Basti Ortiz (Some Dood)

This series by Fun Fun Function seems to be a great start in understanding the fundamental concepts of functional programming for those with a background in JavaScript. I mean, at least it surely helped me understand them.

Collapse
mandarvaze profile image
Mandar Vaze

To others responding to this question:
I am a python programmer who wishes to learn FP.

In past I have "dabbled" with Elixir - Self learnt via their documentation, did Udemy course and also published a package on hex.pm

Then I "lost touch".

I recently came across coconut Being python programmer, I am intrigued.

My generic question (aside from choice of language) : What are your suggestions to adopt "Functional" mindset ?

Collapse
avalander profile image
Avalander

Coconut looks interesting, I'll definitely check it out.