Ask: Functional Programming: Where to Start?
The, "Why I Hate Lisp" post that's been on the top of the page all day finally prodded me to start reading PG's writings on Lisp. I have a BS in Math, so my curiosity is piqued and I want to start learning functional programming.
Currently I develop in C#, Javascript, Python, PHP, and Java (ordered by proficiency).
I want to get suggestions from the HN community on which functional language (or language that supports functional-esque programming) is the best place to start with the criteria for "best" being, you can also recommend a well written book to go along with the language and that the language might allow me to leverage my current experience (unless the pure kick-ass-ness of the language outweighs any benefit I might gain by leveraging my experience. i.e. Scheme > F#).
Thanks!
9 comments
[ 3.2 ms ] story [ 37.0 ms ] threadOnce you know FP techniques, you can apply them in many languages people don't tend to think of as functional (though tail-call optimization helps, and support for higher-order functions is all but necessary); I write strongly FP-influenced code in Lua, for example.
Scheme is also an utterly fantastic language, but I'm going to defer recommendations there to others. (Except: I really like Chicken - http://www.call-with-current-continuation.org/)
OCaml would be nice too, for you, since F# is at least as powerful as it, and you could start using that in your C# environment.
I just started immersing myself in RWH (had to take a brief break from it because I switched clients) but I really liked the book.
Naturally I agree with apgwoz that SICP is another good place to start if you decide to go with Scheme. It is definitely a book every programmer should read, so you do get two for the price of one ;-)
Good luck.
I found SICP nice. You can try to do the exercises in Haskell, too.
Paul Graham's ANSI Common Lisp is a useful supplement but it's not as entertaining as his essays.
If you're learning FP, you're learning AI. Peter Norvig's Paradigms of Artificial Intelligence Programming is the best book for applied FP.
Finally, the best way to learn Lisp is to write your own. It's the easiest language to write and in my opinion the only way to appreciate it.
As for what functional language you want to end up using...well, it depends on your goals.
I'm personally partial to the family of languages which use ML-style type systems, which include OCaml, F#, and Haskell.
The core of F# and OCaml are very similar. F# has better libraries whereas OCaml has both a more powerful type system and more powerful module system.
Haskell is less straight forward than OCaml and F# and has many more esoteric features you need to learn before being considered an expert. Nonetheless, many have found the process of learning to be a mind-expanding process. Also, the Haskell community is much larger and more vibrant than what you'll find with any other statically typed functional language.