I come from a background of a large variety of languages but my only experience with functional programming languages was a brief stint with OCaml. I want to dive a lot deeper into one of these languages (Lisp/Scheme, Erlang, Scala, Haskell, etc.) but I want it to hopefully be one that is practical in working environments and also has a decent user community and documentation. Any suggestions??
- Scheme (PLT), then
- Haskell
Edit: If you decide to go for Scheme, check the Structure and Interpretation of Computer Programs lecture series and book.
Haskell seems to be the current darling of the functional language community, and I don't say that pejoratively. It has a lot going for it and it still under heavy active development and comes with a very supportive community.
F# is very similar in those respects, and has the added backing of the .NET and Visual Studio ecology. You'll also be familiar with its OCaml backbone.
The most broadly used functional language appears to be Haskell, although I suspect F# might be coming on, at least in Microsoft-land, since it's a .net language.
Erlang is also widely used, and is particularly interesting in that it handles highly concurrent multiprocessing systems, and fault-tolerant systems, well.
Lisp-family languages, like Common Lisp, Scheme, Clojure, and so on, aren't really purely functional languages, althogh they can be used in a functional style. To realy get the feel of functional programming, though, you're be better off with a true functional language.
F# is coming really nice way. It has performance profile close to C but is a native .NET.
Given its support for the Windows Azure cloud computing, F# devs will be in a demand rather soon.
My list of languages:
Where first six languages are almost same good and hard to sort.
If you want something practical, use Python. If you're there just for research or enlightment, go for Lisp/Scheme.
Lisp and OCaml are nice, but they are impure languages. Additionally, OCaml supports objects, so theres a tendency to write Java in an OCaml syntax for first time OCaml programmers. I don't know about Erlang -- at the very least, if you're learning a functional language for the first time, it should be a language that allows you to write short throwaway scripts, and Erlang isn't very well suited for that.
Honestly, I would recommend Haskell because it forces you to think about programming differently. Its a pure functional language and you can't fall back on objects when you approach difficult problems. Once you learn Haskell, you'll have an appreciation for all functional languages. Once you finally "get" Haskell, all other functional languages a piece of cake.
You'll want to aim eventually for Haskell, since that's where all the action is, but if you're just getting started I think you're better off with material that is designed for people who are just getting started:
Try The Little Schemer or How to Design Programs, whichever you find more to your taste. In either case PLT Scheme is an excellent programming environment and (unusually) has good "beginner modes".
If you're desperate to dive into Haskell, you might want to look into Helium, which is an environment designed just for learning Haskell, but it is much, much less mature than PLT Scheme.
F# is going to be very cool, but it is really a hybrid of core ML and .NET. As other have already observed, when you're learning you want a language that takes the "pure functional" approach, not a hybrid language. Standard ML is another very nice language to learn, but the programming environments are not as nice and the learning community is smaller (as is the overall community).
Haskell is great as a first functional programming language (as in the process of learning FP) mainly for:
- its purity, and;
- because it's lazy-by-default, which forces you to think in a more declarative, functional way.
Lisp/Scheme as first functional programming languages, in contrast, being more "multiparadigm" ones, will let you "cheat" (as in being imperative) when cornered. Well, you could always use Haskell's IORefs all over the place just as well, but the type system will punish you with the dreadful IO monad ;-)
About the practical aspect, there's a whole community trying to get this point across (Haskell Communities and Activities Report). Also, there's a lot of activity in hackage nowadays (as of this writing, there are almost 800 libraries available there).
There's a great online book to get you started (Real World Haskell) and also a guide for beginners (Learn You a Haskell for Great Good!).
Enjoy !
I've tried various functional programming languages but I can't say that there's one that I think meets all your requirements.
To explore the functional style of programming, Haskell and Erlang are good. These help you avoid programming imperatively.
There are several aspects to the practicality issue:
a) A pure functional style does not cope well with every type of problem. Occasionally, it's nice to be able to escape into an imperative or object-oriented style. Ocaml, F# and the Common Lisp are amongst languages that allow you to do this.
b) Good library support means that you won't need to reinvent the wheel or write code that interfaces with libraries written in other languages. F# is good in this respect. Commerical implementations of Lisp also provide good library support.
c) Acceptability at work. My opinion is that a programming language with a good public image is essential, if you want to see it being adopted by others where you work and want to see it used for production quality or deliverable software. If managers and colleagues are open-minded and enlightened, then this is not an issue.
There are three interesting areas:
- Haskell - lazy (and therefore has to be pure)
- ML-Dialects (OCaml, F#, ...) - eager and impure
- Lisp-Dialects (Scheme, Clojure, ...) - eager and impure, and very simple to learn but maybe a bit odd for the first 15 minutes because of the S-Expressions (prefix-notation)
A lot of other functional languages are also interesting (Erlang, ...).
My vote would be for Hakell. "Real World Haskell" is a great way to start.
As books are frequently (and justifiably) offered as an important aid in picking up a language, I'd like to add my own experience with Haskell books. I have been poking around Haskell for years, looking into books like Paul Hudak's "Haskell School of Expression" and the recent "Real World Haskell" by O'Sullivan et al. And altough I appreciate the effort and care that went into these books, neither were for me. Being a programmer for some years, I am tired of verbose text books that are overly anxious not to go too fast. I have a need for crisp, terse introductions that give me the essentials of a programming language, fast in as little text as (sensibly) possible. And finally, I think I found the book that might break the ice for me. It's Graham Hutton's "Programming in Haskell". On roughly 150 pages it offers Haskell condensed, concepts in one piece, examples that are short and to the point, clear outline. It gives me an excellent overview, a feel for the essentials. Everything that might be beyond its scope I can easily fill in from other (online) material. That's the way I like to learn a new language.
I would start with Erlang. It is very easy to learn, compact, relatively nice syntax, widely used and supported, there are free implementations available for most platforms, has a powerful framework for soft real-time problems (OTP), and has nice extras like it is very simple to develop distributed applications on.