Hacker News new | ask | show | jobs
Which functional programming language should I choose to learn?
10 points by iklavya 5446 days ago
Having programmed in C++ for several years and having read HN for several months, I would like to learn a functional programming language to expand/change the way I think about writing programs. Which functional programming language should I choose? Python, Ruby, Haskell, others? It would be nice to have decent library support so that I can actually write a web based product using it and host it somewhere :). Please advice
5 comments

First of all, I'd work on your list. While it's pretty clear what "functional programming" is, the definition of "functional language" is a bit more vague. Still, everyone agrees that Haskell is a functional language. Also, just about everyone agrees that Python and Ruby, while offering some support for functional programming, can hardly be considered functional languages.

When people talk about "functional languages", they mean things like Haskell, OCaml & other ML-ish languages, Scala, F#, and the various dialects of Lisp (EDIT: and, yes, Rust).

If you really want to expand/change the way you think, then I'd say Haskell is what you want. As for libraries, there is a huge amount of work going into Haskell libraries & bindings for existing libraries. I'm not really able to judge whether any of this work is any good, however.

Scala and Clojure (Lisp dialect) have also been getting a lot of attention lately. They both run on the JVM, and so should have excellent library support.

Also, just about everyone agrees that Python and Ruby, while offering some support for functional programming, can hardly be considered functional languages.

Wait to see how many people here suggest Ruby or Python, or JavaScript, though.

If you really want something to change the way you think, I would suggest Scheme while reading SICP "Structure and Interpretation of Computer Programs". I believe MIT makes the newer version of the text available online, and the old MIT Open Courseware lectures that go along with the old version are very good. Also, the book "The Little Schemer" is a great way to get a handle on recursive thinking. Scheme is also very similar to the low level abstract syntax tree format of some kinds of compilers, so if you are interested in compiler theory it may be useful to know.

Erlang can be sort of considered a "Scheme with syntax". However, it is also somewhat weird, and if you're just starting with a functional language, you might as well go for Scheme.

I personally don't know that I'd recommend Haskell as a starting functional language. If you want to learn Haskell, I might suggest stating with Erlang as a baby untyped Haskell, and then move up to Haskell.

Also, Javascript is more functional than is generally realized, however, it's functional flavor may be more obvious after you have been exposed to an explicitly functional language.

One last thought, if you are interested in Web programming, Clojure is a functional flavored version of Lisp that runs on the JVM, and has a web framework called Compojure that seems well regarded.

I started with Erlang, to pick up the basics of functional style, and then tried Haskell. It was a breeze, but I alreadt had C#+LINQ and Ruby experience.
This. SICP is a fantastic book. Buy it, then read it. Twice. Or more.
Although I started with lisp, I think it's a good idea to learn Haskell first. The type system and especially the type signatures can act as a visual reminder about the "core" of functional programming: having an input of this type and requiring an output of that type, which transformations (functions) should I use to accomplish this?
Python (though not by any means a functional language), offers many functional programming constructs like map, filter, zip etc. If you want to transition slowly into "thinking" in a functional language, I suggest you can get started on that path with Python.

If you want to take the jump straightaway - I will suggest going for Erlang. Erlang has plenty of nice web libraries like mochiweb, nitrogen etc. using which you can actually write a web based product.