Ask HN: which functional language to learn?
I'm looking at learning a functional programming language, but not able to decide which one. The language should be fun to learn and also have decent job opportunities.
Based on some initial reading, Haskell and Erlang seem to be good choices. Can anyone suggest a language?
My background (not sure if it matters) I've worked with Java/PHP/Ruby, developing desktop and web applications.
47 comments
[ 7.0 ms ] story [ 173 ms ] threadIf it were the usual programming languages (PHP, Ruby, Python etc), making a choice is relatively easy. For functional languages, I'm not sure where to even begin.
What do you mean by that? Is it just that you know this field better and thus feel better informed, or are you hinting at something else, that I didn't get?
Whereas with functional programming, I am totally new and lost, no clue where to even begin.
No, I didn't hint anything else.
OTOH, if you are really interested in being truly pure, it's hard to beat Haskell. Real World Haskell is a great intro for that language, and it's free online.
That said. Scheme with SICP, or The Little Schemer and then SICP
Do you mean it gets difficult, or that progress gets fast?
Once you've written some code and feel comfortable with FP, then drink the Haskell-aid.
http://learnyouahaskell.com/
http://book.realworldhaskell.org/read/
It's strange, but Haskell is more difficult to read than write. This is because most code on e.g. Hackage uses some very complicated gymnastics involving Applicative, Arrows, or whatever. So it's hard to learn from other people's programs.
Also, a warning: learning Haskell might screw with your ability to write code in other languages! It took me two weeks before I stopped making every line of Python a lambda.
map (find needle) haystacks
is clearer (as well as shorter!) than
map (\haystack -> find needle haystack) haystacks
In most other languages things like partial application are a pain to express, so a lambda is an easier way out.
(Now I'm imagining the six lines of Java I'd have to write to achieve the same effect as those four words of Haskell, and trying not to giggle. Functional style is addictive.)
I find myself using them in Python everywhere as a substitute for currying and/or laziness, e.g.:
http://www.haskell.org/tutorial/
For those already proficient with programming that just wnat to pick up Haskell, it's ideal.
Then I would suggest an exercise that involves manipulating abstract syntax, for example parsing and interpreting a little language. ("Build yourself a Scheme..." might be good though I didn't read it myself.) This is where the language really shines, and you don't need any of the recently popular trickery like arrows or GADTs.
Go with Scala, Clojure or Haskell. The first two run over the JVM and seem to have a very nice community behind them. Haskell is very cool and it will definitely change the way you look at programming.
There is also F# which is very cool and runs over the .NET framework. If you're into Microsoft stuff then it might be worth it.
Scala started earlier than Clojure and has a bigger community around it. Clojure is clean and grows quickly, it has a very good potential. Besides, it has a strong and multifaceted support for parallel (multicore) programming. Both Scala and Clojure run on top of JVM and interop with it.
Haskell has had a strong following in academia for quite a while now. Newer languages borrow from it.
I have not tried F# which, as far as I understand, is a kind of ML on .NET. Its community seems to be smaller, but it may be due to the usual animosity some people feel regarding anything that comes out of Microsoft. Reportedly the language is well designed.
Emacs coupled with SLIME provides the best development environment I have yet experienced. For me, the greatest downside is that the code I end up with is often quite system-specific.
So, unless you need to support or interact with past Lisp code, I think Clojure may be a better tool for most of us. YMMV, as usual.
[1]http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m...
See: http://en.wikipedia.org/wiki/Function-level_programming#Cont...
Of course, when we are talking about a group effort, we need a technology that everyone in the group is understanding. It is more difficult to convince others (including management) in a Microsoft shop to use non-Microsoft technologies. But it is possible.