11

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?

DPD
  • 3,527

4 Answers4

19

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.

Thomas Owens
  • 85,641
  • 18
  • 207
  • 307
3

'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.

tdammers
  • 52,936
2

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.

1

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.

Eric Wilson
  • 12,111