foobar on computers, software and the rest of the world


Exploring functional programming - Which language do you recommend?

, posted: 11-Dec-2008 03:08

I need your advise. I am thinking about broadening my horizon and learning about functional programming. So now I'm wondering: Which language would you recommend I use for this learning exercise?

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)?
Ideally, whatever material I need to learn the language should be available online.

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:

http://www.jsoftware.com/

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 (steven.e.ashley@gmail.com) on MSN or Google Talk or fire me an email.
Good luck!


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
        where
            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

I know this is old, but I felt like adding in something that's a bit overlooked: JavaScript.

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.

However, the web is becoming more and more important all the time. JavaScript has support for a wide variety of paradigms, including functional. It also uses a lot of C syntax, so it should be familiar to you (for better or worse).

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.

P.S. It also uses prototypes, rather than traditional classes. I personally consider this an extremely good thing, and not a handicap at all. Yet another quirky (in a good way) reason to check out JavaScript.

P.P.S. There's about 5 quintillion tutorials about JavaScript out there. About 4.9999 quintillion are horrendously awful. It can be worth it to find the few that are good, though.


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?


Add a comment

Please note: comments that are inappropriate or promotional in nature will be deleted. E-mail addresses are not displayed, but you must enter a valid e-mail address to confirm your comments.

Are you a registered Geekzone user? Login to have the fields below automatically filled in for you and to enable links in comments. If you have (or qualify to have) a Geekzone Blog then your comment will be automatically confirmed and placed in the moderation queue for the blog owner's approval.

Your name:

Your e-mail:

Your webpage:

foobar's profile

 
New Zealand


  • Who I am: Software developer and consultant.
  • What I do: System level programming, Linux/Unix. C, C++, Java, Python, and a long time ago even Assembler.
  • What I like: I'm a big fan of free and open source software. I'm Windows-free, running Ubuntu on my laptop. To a somewhat lesser degree, I also follow the SaaS industry.
  • Where I have been: Here and there, all over the place.




Google Search


Recent posts

Attack on net neutrality right...
Munich already saved millions ...
Iceland's public administratio...
More Apple madness (follow up)...
Apple demonstrates: With great...
Smooth sailing with the Karmic...
Censorship in New Zealand: Wid...
Image roll-over effects withou...
How about: Three strikes and Y...
UK government supports open so...


Top 10

How to write a Linux virus in ...
(11-Feb-2009 06:33, 457962 views)
Follow up: How to write a Linu...
(12-Feb-2009 08:10, 64351 views)
A truly light-weight OS: Writt...
(3-Feb-2009 10:39, 46493 views)
The 'Verified by Visa' fiasco ...
(20-Jun-2008 09:59, 32265 views)
EEE PC with XP is cheaper than...
(9-May-2008 06:50, 20200 views)
11 reasons to switch to Linux...
(4-Feb-2009 09:24, 20115 views)
Would you use Google App Engin...
(8-Apr-2008 20:02, 19393 views)
Censorship in New Zealand: Wid...
(16-Jul-2009 12:11, 18845 views)
Django Plugables: Tons of plug...
(11-Apr-2008 03:24, 16797 views)
Slow file copy bug in Vista: A...
(21-Dec-2007 12:18, 15926 views)