
Ask HN: What functional programming language should I learn? - xfax
I&#x27;ve dabbled in functional programming languages over the years but never got around to getting good at any one of them. I want to change that this year and build up some expertise. The question is, what language should I pick?<p>Here&#x27;s what I have dabbled in in the past -<p>* Haskell
* OCaml
* Clojure
* F#
* Elixir
* Scala<p>What would you recommend? I want to be able to build simple CLI programs as well as use it for web application development (for hobby projects).
======
brudgers
I tend to think of functional Programming as an idiom. Sure some languages
make it _harder_ and some make location based programming nearly
impossible...except that once you're on the web making remote calls to REST
API's even the most functional friendly languages can't do better than a
saying the value is the warning-warning-could-be-anything-type...which means
that from a functional perspective a function that calls a REST API always
returns the same value regardless of input parameters or it's not a function.

And that's ok by me. Because the idiom of functional programming is a gestalt
of figure _and_ ground. The ground is knowing when to _explicitly_ use place
based methods -- Under the hood, so long as we have computers based on the Von
Neumann architecture everything we do ultimately gets distilled into place
based computing that mutates values. Functional programming is just a way of
abstracting over that when it is productive to do so.

Functional programming, like object oriented programming, is a set of clever
abstractions not magic. There aren't functional programming computers (or
object oriented computers) that are different from imperative mutating
machines.

Anyway, I guess the point is that functional programming shares quite a bit
with test driven development. It's more a matter of programmer behavior than
language. And thus my advice is to start writing functional code in whatever
language is at hand: functional programmers who use PHP write functional code
in PHP.

Of course it's always fun to play with a new language which is orthogonal.

Good luck.

------
pmarreck
Elixir is fantastic to work with and has a bright future (its conference
attendance has doubled every year), although its libraries (as impressive as
they are) might not be as mature as some of the older functional langs. The
tooling is fantastic, though

------
yawaramin
Are you a relative newbie at functional programming? Do you have about a
month? Then I highly recommend Prof. Dan Grossman's free online course:
[https://www.coursera.org/learn/programming-
languages/](https://www.coursera.org/learn/programming-languages/)

He teaches the syntax, semantics, and idioms of ML-style typed functional
programming using the Standard ML language as a teaching vehicle. His
explanations and course progression are really good. It will open your eyes to
FP.

------
kirankn
Elixir/Phoenix & Elm

------
nlander
I strongly recommend that you learn Haskell.

I have some reasons to back up my endorsement of Haskell.

First and foremost, Haskell is the best language to learn if you want to learn
about functional programming. Why? Because Haskell is the quintessential
functional programming language. It is approaching 30 years of age and was
originally developed back when functional programming was nowhere to be found
in production settings. A bunch of academics who were all working on separate
functional programming languages got together and said, “hey, how about we all
work together and make the ultimate FP language rather than reinventing the
wheel on our own?” And that’s exactly what they did. The result today is a
very mature, feature rich and programmer-friendly language. If you really want
to delve into the history of Haskell, check out this paper or watch the video
based on it:

[https://www.microsoft.com/en-
us/research/publication/a-histo...](https://www.microsoft.com/en-
us/research/publication/a-history-of-haskell-being-lazy-with-
class/?from=http%3A%2F%2Fresearch.microsoft.com%2Fen-
us%2Fum%2Fpeople%2Fsimonpj%2Fpapers%2Fhistory-of-haskell%2F)

The second reason to learn Haskell is that it is a great language for doing
the things you want to do. A prominent Haskeller, Gabriel Gonzalez, estimates
that Haskell is mature in the domain of server-side web development. Check out
his view on the state of the Haskell ecosystem:

[https://github.com/Gabriel439/post-
rfc/blob/master/sotu.md#s...](https://github.com/Gabriel439/post-
rfc/blob/master/sotu.md#server-side-programming)

Writing CLI programs is also rated mature in the same article:

[https://github.com/Gabriel439/post-
rfc/blob/master/sotu.md#s...](https://github.com/Gabriel439/post-
rfc/blob/master/sotu.md#scripting--command-line-applications)

If you want to do front end web programming, I highly recommend checking out
PureScript:

[https://leanpub.com/purescript/read](https://leanpub.com/purescript/read)

This might be an even better starting point for you if your background is in
JavaScript (you don’t mention which languages you have experience with).

The third reason you should choose Haskell is that there are some great
educational resources out there. Most notable among them is this book:

Haskell Programming from First Principles:
[http://haskellbook.com/](http://haskellbook.com/) This book is the most
thorough, pedagogically sound, and practical book out there. It is what you
should read if you have any interest in ever using Haskell in production.

For excellent exercises, check out Programming in Haskell:
[http://www.cs.nott.ac.uk/~pszgmh/pih.html](http://www.cs.nott.ac.uk/~pszgmh/pih.html)

For something free but somewhat problematic (the author will call you fat) and
not very in depth, check out Learn You a Haskell for Great Good:
[http://learnyouahaskell.com](http://learnyouahaskell.com)

For blog posts that will expose you to some of the many libraries in the
Haskell ecosystem, or some of the language extensions that are heavily used in
production Haskell, check out the 24 Days of Hackage series:
[https://ocharles.org.uk/blog/](https://ocharles.org.uk/blog/)
[http://conscientiousprogrammer.com/blog/2015/11/30/haskell-t...](http://conscientiousprogrammer.com/blog/2015/11/30/haskell-
tidbits-24-days-of-hackage-2015-day-1-introduction-and-stack/)

The fourth reason you should learn Haskell is that the compiler makes
everything easier. You don’t have to be super smart to program in Haskell
because the compiler is smart for you. It will catch most of your mistakes and
prevent so many errors. This could be an argument for many statically typed
languages, but the fact is that Haskell has the most expressive type system of
any language used in production.

The fifth reason you should learn Haskell is that it has a great tool for
managing dependencies:
[https://docs.haskellstack.org/en/stable/README/](https://docs.haskellstack.org/en/stable/README/)
This tool and other work done by the company FP Complete
([https://www.fpcomplete.com/](https://www.fpcomplete.com/)) are the main
reasons that Haskell is a great option for production applications and not
just a research language like it used to be.

I hope this has convinced you. I love programming in Haskell and I am having a
blast learning it. There is so much to learn about functional programming and
I would still consider myself an advanced beginner, or maybe just barely
intermediate. I hope you have as much fun learning Haskell as I have and
continue to. Cheers and best of luck!

 _Disclaimer_ Haskell is the first and only language that I have used in any
kind of professional context, and I cannot even claim to be a beginner in any
of the other languages you mentioned. I have recently begun coding in
PureScript, but that’s basically the same language.

------
Learn2win
Haskell has very mature libraries to build web and CLI programs.

