13

Possible Duplicate:
How to grasp functional programming concepts?

I'm looking for some resources on functional programming subject. It seems to be a paradigm which is gaining visibility and I wanna know a bit more of it.

What are the books/ebooks/articles do you recommend?

Note: I'm not necessarily looking for a specific language, but for the paradigm itself.

4
  • 1
    You should be learning the paradigm through a language, I guess Commented Mar 8, 2011 at 16:04
  • @Mahmoud yeah, what I meant was I'm not looking for a functional language tutorial/ebook, however I wanna use a language as a tool for better theory understanding :-) Commented Mar 8, 2011 at 16:07
  • 1
    I found real world haskell helpful. Commented Mar 8, 2011 at 18:46
  • Shameless plug: Functional Programming in OCaml focused on functional programming rather than OCaml, but in the final lectures using imperative features and the module system when necessary. Commented Jun 18, 2013 at 11:25

9 Answers 9

6

The best answer is really going to depend on what languages you currently know. If you're familiar with the C-family, in particular C#, then learning F# would probably be most practical. You'll pick up all the fundamentals of functional programming, but be able to blend in OOP concepts (like in OCAML). Plus, you can back port most of that knowledge into C# itself to do minor functional programming in an OOP language.

A good book for this method would be Real World Functional Programming by Tomas Petricek with Jon Skeet. EDIT: Its a good book because it goes over the principles of FP, but shows how to use them in both a Functional language (F#) and an OOP language (C#) so you gain an understanding of not just what to do and why, but also how the computer is really interpreting what you're doing. I think that's always valuable in programming.

On the other hand, you may want a pure approach, in which case I recommend Haskell. Its harder to get started with, but will give you the cleanest and most comprehensive approach to learning just FP concepts.

2
  • Good, seems to be a good resource for learning FP... the examples inside the book will be very helpful. I'll see the table of contents. Thanks in advance! Commented Mar 8, 2011 at 18:32
  • F# is not like OCaml. Even though you can write simple programs that compile under both. Commented Jun 18, 2013 at 11:23
17

What can I say besides: Learn You a Haskell for Greater Good!

the funkiest way to learn Haskell, which is the best functional programming language around. You may have heard of it. This guide is meant for people who have programmed already, but have yet to try functional programming.

The whole thing is completely free to read online, but it's also available in print...

5
  • 1
    eh, I don't really think that's very good. Commented Mar 8, 2011 at 20:46
  • 2
    @Paul Nathan Why? I enjoyed it greatly, that's why I recommended it. It would be interesting to hear what you didn't like about it instead of just "I don't really think that's very good". Commented Mar 8, 2011 at 20:48
  • 1
    it's sort of useful in a hand-holding way or to check a given syntax in haskell. I have not found it remotely useful to engage me in how to think in a pure functional fashion (or for that matter, how to wrap my head around the type system). Commented Mar 8, 2011 at 21:02
  • @gnat this question is over 2 years old with more than 10 upvotes, I feel like it can be left alone. Commented Jun 17, 2013 at 4:38
  • @PaulNathan Disagreed. LYAHFGG is an awesome resource for beginners to functional programming. It certainly helped me, and I knew nothing about Haskell's type system. It's not enough for advanced users, but that's not its purpose. Real World Haskell might be better for that. Commented Jun 18, 2013 at 18:56
6

In reference to Vitor's response Learn You A Erlang. For a more language-agnostic (theory based view) you could start with Lambda Calculus.

9
  • Recommending lambda calculus here is like recommending electrical engineering in order to learn programming in general. Commented Mar 8, 2011 at 16:20
  • 1
    @delnan, functional programmin is lambda calculus. You can't learn one without another. Commented Mar 8, 2011 at 16:29
  • @SK-Logic: Programming (idiomatically) in any real-world functional language and solving problems has little to do with learning the math/theory behind the concepts you're using there. In fact, if you understood the former the latter seems like both more theoretical and less powerful - there's a lot more about FP than defining an applying (recursive) functions. Even super-simple lisps are built on more things (you have lists, numbers, strings, booleans and possibly more types, you have macros, etc.). Commented Mar 8, 2011 at 16:32
  • @delnan, OP is asking about a paradigm. It is not easy to comprehend a paradigm without a theory. Practical examples in any particular language won't help. Commented Mar 8, 2011 at 16:36
  • @SK-Logic: Burying OP in a super-simple, theoretical/formal system that happens to include some of the core concepts on FP won't help. What's better to make a programmer embrace e.g. recursion, math oder practical examples? Yes, no language represents the whole paradigm. But it can be used for examples of large parts of the paradigm (more than lambda calculus even touches - there are lists in basically every FP language!). Commented Mar 8, 2011 at 16:41
6

People here have been recommending Scheme and specifically this course as an intro to procedural/functional programming.

I didn't follow the whole course, but I really learned a few things even though I just watched the first video.


If you find SICP hard to follow, you can also learn Scheme using this book.

2
  • 2
    You mention SICP, but you might also want to point out the Little Schemer Trilogy, which is excellent for beginners to functional programming. Commented Mar 8, 2011 at 16:57
  • @Inaimathi you can put it in a new answer :) you'll get more rep for that Commented Mar 8, 2011 at 17:02
4

Why don't you write yourself a Scheme using Haskell.

Learn two functional languages at the same time!

48 hours is probably a bit optimistic as you would want to read around and play with the concepts to make sure you fully understand whats going on before proceeding on..

2
  • IMO, this is most useful for Schemers who want to get into Haskell (or perhaps Haskellers who want into Scheme). I doubt someone who knew neither language would benefit much. It is a great exercise to go through though. Commented Mar 8, 2011 at 16:55
  • This is good. I've learned a bit of LISP, so learning Scheme and Haskell will be a great experience. Thank you. Commented Mar 8, 2011 at 18:35
4

The Little Schemer Trilogy is a great resource for learning the basics. Most Lispers I've met actually recommend going through the first one, then moving on to On Lisp (which is available for free at the authors' site).

3

I have been working through the following book: http://www.amazon.co.uk/Real-World-Functional-Programming-Examples/dp/1933988924/ref=sr_1_1?ie=UTF8&qid=1299602802&sr=8-1

The examples are in F# and C# so they might be a bit too Microsoft centric for your needs. I can recommend the book though; I am slowly beginning to 'think functionally' about certain problems.

1
  • I work with Microsoft technology, so it won't be "too centric". Also, there is mono ;-) Commented Mar 8, 2011 at 18:34
3

The Charming Python: Functional programming in Python from IBM Developerworks really helped me to understand what functional programming is.

This article is for Python, but I think the code examples in this article (in which doing different things functionally and procedurally are contrasted) can clarify the difference between procedural and functional programming for any programming language.

3

The concept behind functional programming is called "lambda calculus".

The canonical and the most comprehensive book on lambda calculus is Barendregt, H. P. "The Lambda Calculus: Its Syntax and Semantics."

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.