Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
Choosing a functional programming language

I am a C++ programmer looking to learn a functional language as a hobby and out of sheer curiosity. I am not looking to be an expert, but just to get a grasp on functional programming. This language should be simple to learn and have good tutorials and resources for beginners. Are there any such languages?

share

locked by World Engineer Apr 27 at 0:55

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

marked as duplicate by Walter, ChrisF Oct 18 '11 at 16:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Note to closers: I did see the query: "Choosing a functional programming language" but it is by someone who has been intorduced to functional programming. My query was from the point of view of a person who hasnt learnt functional programming at all. –  DPD Oct 27 '11 at 13:43
    
Thanks everyone for your replies. –  DPD Oct 27 '11 at 13:43

4 Answers 4

up vote 20 down vote accepted

I've found that Haskell has a number of good resources available. It's also a purely functional language, meaning that any identifiers are immutable. As far as resources to learn the language, it has a comprehensive website and a highly recommended tutorial that is also available for purchase as a book. Real World Haskell is also another good book available for purchase or online for free. Haskell is also somewhat common on Stack Overflow, with over 4000 questions asked and many answered.

However, one of your requirements is "simple to learn". That's hard to judge. Coming from a C++ background, I suspect that you have a strong object-oriented and/or procedural background. Functional programming requires a totally different thought process - it will warp your mind, but it will also make you a better engineer if you are able to think in a new and very different way. You might be interested in the answers to this question about learning functional programming to become a better object-oriented programmer.

share
4  
BTW, Real World Haskell is available for free in the internet. IMHO it is one of the most "functional" language you can learn. –  FUZxxl Oct 18 '11 at 12:49
    
@FUZxxl Thanks for that. I own a copy of the book - I was unaware it was freely available as well. –  Thomas Owens Oct 18 '11 at 12:58
    
Me too. It's really a good book, but not so much recommendable for people with no functional background. Many people say that the explanations for basic concepts are not very good, though I think they are sufficient for a good explanation. If you ask questions on [haskell], I am happy to answer you. –  FUZxxl Oct 18 '11 at 13:04
    
@FUZxxl That might be true. Prior to starting to learn Haskell on my own, I was exposed to Scheme and Standard ML in coursework, so I had some functional experience. The book was highly recommended by a friend, and it is a fantastic book, but I can't judge it from the perspective of someone without a functional background. –  Thomas Owens Oct 18 '11 at 13:06
    
+1 Thanks Thomas, That was a really detailed answer. I will go with Haskell as you have suggested. –  DPD Oct 27 '11 at 14:29

I ran into two of them that I would qualify as simple to learn:

  • Scheme (a Lisp dialect, dynamically typed)
  • Standard ML (statically typed)

I personally prefer SML; if you decide to look at it, my suggestion is the SML/NJ compiler which also comes with REPL, unlike Mlton which is an excellent optimizing compiler, but maybe a little less comfortable as a learning tool.

share

You have essentially two choices: A language in the Lisp family (Scheme, Common Lisp, Clojure) or a language in the Haskell family (Haskell, ML, OCaml, F#, Scala)

The Lisp languages aren't as pure, but are simple to approach, with a fairly minimal syntax, especially Scheme. Haskell and it's derivatives have a much more complex type system, which is intimidating at times, but allows for more sophisticating thinking about functions.

I recommend Scheme or Haskell, since you aren't looking to make production code.

share
    
+1 ThanksEric. I have decided to start of with Haskell. Maybe I am trying to bite off more than I can chew and if I fail I will definetly turn to Scheme. –  DPD Oct 27 '11 at 14:37

'Simple to learn' is always going to be relative - the biggest burden is making the jump from imperative to functional programming, the syntax is of much less importance. In fact, a radically different syntax might make it easier to pick up the new concepts and approach programming from a completely different angle.

The language itself is probably less important than its surrounding ecosystem - you want to pick one that has an active community, a rich set of libraries, and most of all, good development tools. However, I'd go for a language that was designed for functional programming, rather than a multi-paradigm one that happens to be suitable for functional programming - javascript, for example, has many FP aspects, but it doesn't invite or urge you to use them.

Here's a list of languages you might want to try:

  • Haskell
  • Scheme
  • Common Lisp (CL)
  • ML
  • F# (if you're into .NET)
  • Clojure (if you're familiar with the Java ecosystem)

Of these, Haskell is probably the most radically different from what you're used to.

share
1  
Also, of that list, Scheme, Common Lisp, and Clojure are incredible closely related to each other. F# and ML are also closely related. –  Thomas Owens Oct 18 '11 at 12:48
    
@ThomasOwens: good point. –  tdammers Oct 18 '11 at 12:51
1  
"The language itself is probably less important than its surrounding ecosystem [...]" I disagree with that. There are quite different concepts in functional languages and that influences the flavour of functional programming you learn. Eg. in Lisp, you usually have extensive usage of macros and almost no type system, while you have an extremely sophisticated type system and mostly no mutable stuff in Haskell. In F#, Scala Ocaml you have a good mix of both mutable and immutable stuff. It really IS important which language you choose, though the particular choice depends on what you like. –  FUZxxl Oct 18 '11 at 13:16
    
@FUZxxl: By "less important" (note that I didn't say "not important"), I mean in terms of a learning curve. Of course the differences do matter in the end, but they don't make one of these a better choice as a first functional language. Oh, and Lisps do have a strong type system, they just don't apply it statically. –  tdammers Oct 18 '11 at 13:38
    
@tdammers Sorry. I am not a lisp programmer, so I can't tell very much about it. But of course the language also has an influence to the steepness of the learning courve. –  FUZxxl Oct 18 '11 at 13:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.