My programming experience so far has mostly been in C/C++, Java, Pascal, Assembler and Python. In hindsight I regret that I didn't pay too much attention to that one Lisp class that I had many years ago at university. Maybe the instructor didn't properly convey to us the value of learning a completely different approach to programming? Yeah, that's right, let me just quickly blame it on the professor... :-)
Anyway, I read many times that just learning functional programming can be a bit of a "mind altering" experience, which opens your eyes to better ways of doing things, makes you see the world in a different light so to speak (sounds like an acid trip!) and makes you a better developer even if you work mostly in non-functional languages. So, to get that benefit I guess any decent functional language would do. On the other hand, it would be convenient if that language actually has some commercial relevance as well. Being able to put sought-after skills on a CV is always useful, although I recognise that there are certainly much less commercial opportunities in functional programming than in the 'normal' procedural programming.
So, which language should I focus on? This is what I gathered so far:
- Lisp is the classic, but I heard that it's tough to actually get real-world stuff done, since library support for real-world tasks is not so well developed. I don't want to judge it badly for all its parenthesis, since I'm also not judging Python for the indentation...
- Erlang gets a lot of press and allows for explicit parallel programming, but is only partially functional, which might distract me from my goal to learn about FP.
- Haskell has some compilers that produce very speedy code and also seems to have decent library support, although the compiler's generic error messages make it hard to debug and learn.
- Scheme is like Lisp, just ... different. It's multi-paradigm, which I take to mean that you can also do non-functional programming with it. Don't know if I want that for learning about FP.
- Any other good language(s)?
What would you recommend then? Thank you very much for your advise...
Other related posts:
More Apple madness (follow up)
The GPU, your personal desktop super computer
A truly light-weight OS: Written in ASM, with GUI, networking and apps
Comment by Mark Derricutt, on 11-Dec-2008 09:32
Currently my two favorite "lets look at" functional languages are Scala (http://www.scala-lang.org/) and Clojure (http://clojure.org/). Both of these languages are hosted on the Java Virtual Machine. Scala is an object orientated/functional hybrid where as Clojure is a LISP based language.
Comment by James Sleeman, on 11-Dec-2008 10:55
When I was at Uni, year 1 Cosc taught functional programming with Haskell (using Hugs, which I think has some differences, dim dark distant memory here) in the second semester, I seem to remember it being quite enjoyable.
Wolfgang Kreutzer and Bruce McKenzie wrote the text for the course which was distributed as a large photocopy and I seem to remember, pretty good (Wolfgang taught some of the course I seem to remember). God knows where my copy is though, if it has survived at all.
Wolfgang's website appears to list it still as an unpublished draft: http://www.cosc.canterbury.ac.nz/wolfgang.kreutzer/fpBook.html - I think not long after I was done all year 1 work moved to Java, so I guess they didn't publish.
Later at Uni I also used a Lisp dialect (may have been Scheme, dim dark....) and recall just one thing about it, if in doubt, add another parenthesis. I wasn't a fan of the syntax.
Comment by Tracy Harms, on 11-Dec-2008 14:18
The language I chose for functional programming is J, an unusually powerful multiparadigm language:
Although J does not have the lazy evaluation that makes Haskell so interesting, the function-level technique emphasized by J is outstanding. Coupled with the pervasive array-handling native to any Iverson language, it facilitates abstraction and composition in a remarkable way.
Comment by Rob Singers, on 11-Dec-2008 16:33
Back in the dark ages when I did Comp Sci we were forced to program in a diabolical language called Hope Plus C. The idea of a functional language was interesting but I don't think it taught us anything.
If you want to extend yourself I'd look at both Lisp and Prolog. Learning to use both of them will broaden your knowledge of programming without overly aggravating you.
Comment by StevenAshley, on 11-Dec-2008 21:47
Of those listed I consider Haskell to be the most mind-warping (in a good way of course).
Haskell is a particularly interesting language as it is lazy, pure and has a very strong type system. This leads to some interesting styles of programming. See if you can get your head around the following definition for an infinite list of fibonacci numbers.
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
The best book on the subject without a doubt is http://book.realworldhaskell.org/read/
User contributed libraries are located on Hackage http://hackage.haskell.org/packages/archive/pkg-list.html
Documentation on a bunch of modules is here http://www.haskell.org/ghc/docs/latest/html/libraries/index.html
I have been using Haskell (ghc) for the past 3 or so years and have few complaints. It is an extremely flexible language suitable for anything from low-level bit-munging to combinator parsing to GUIs.
The compile error messages given by GHC give a lot of context. I havn't had any issues with them.
The runtime errors on the other hand can be tricky to track down. The Debug.Trace package comes in handy. (I understand there have been some improvements to GHC recently so that it gives a stack trace when it dies).
More recently I have been having a look at Clojure. If you like lightweight languages, this may be a better option. Haskell is a bit of a beast.
Prolog is another mind-warping language. However it seems it has gone out of fashion.
If you have any Haskell related questions, feel free to add me (firstname.lastname@example.org) on MSN or Google Talk or fire me an email.
Comment by griffonrl, on 14-Dec-2008 16:04
Erlang, the next big thing.Reliable, scalable, parallel programming friendly.
Comment by adam77, on 15-Dec-2008 15:26
OCaml the last next big thing.
Comment by Jordan, on 16-Dec-2008 09:05
If you know python, you can program almost completely functionally in it. However, if you really want to learn, write scheme code. If you really, really, really want to learn, and wish to despise programming in any other method or fashion qua functional programming, you want haskell. Shit's bananas, buddy. Take a look at this fibonnaci sequence:
fib :: Integer -> Integer
fib n = fibs !! n
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
DO YOU SEE THIS SHIT?! Equivalent to a python generator (they stole it from haskell). Hawt.
Comment by Pauan, on 30-Jun-2009 19:45
Wait! Hear me out! Yes, it's quirky. Yes, it's interpreted. Yes, it's basically just-for-the-web. Yes, it's very dynamic. Yes, it lacks some very nice features that other languages have.
It's probably not the best if you want to really learn functional programming (try something more like Lisp), but it's still a neat language, so you should check it out.
Comment by jgksadjgdksajglk, on 19-Apr-2011 20:56
Did you ever learn a functional language? Which one? What did you think of the experience?