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.

Herberth Amaral
  • 471
  • 3
  • 10
  • 1
    You should be learning the paradigm through a language, I guess – Mahmoud Hossam Mar 08 '11 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 :-) – Herberth Amaral Mar 08 '11 at 16:07
  • 1
    I found [real world haskell](http://book.realworldhaskell.org/read/) helpful. – dan_waterworth Mar 08 '11 at 18:46
  • Shameless plug: [Functional Programming in OCaml](http://www.ii.uni.wroc.pl/~lukstafi/pmwiki/index.php?n=Functional.Functional) focused on functional programming rather than OCaml, but in the final lectures using imperative features and the module system when necessary. – lukstafi Jun 18 '13 at 11:25

9 Answers9

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

gnat
  • 21,442
  • 29
  • 112
  • 288
Vitor Py
  • 4,838
  • 1
  • 27
  • 33
  • 1
    eh, I don't really think that's very good. – Paul Nathan Mar 08 '11 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". – Vitor Py Mar 08 '11 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). – Paul Nathan Mar 08 '11 at 21:02
  • @gnat this question is over 2 years old with more than 10 upvotes, I feel like it can be left alone. – daniel gratzer Jun 17 '13 at 04: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. – Andres F. Jun 18 '13 at 18:56
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.

Mahmoud Hossam
  • 3,817
  • 2
  • 29
  • 41
  • 2
    You mention SICP, but you might also want to point out the [Little](http://www.amazon.com/Little-Schemer-Daniel-P-Friedman/dp/0262560992) [Schemer](http://www.amazon.com/Seasoned-Schemer-Daniel-P-Friedman/dp/026256100X/ref=pd_bxgy_b_img_b) [Trilogy](http://www.amazon.com/Reasoned-Schemer-Daniel-P-Friedman/dp/0262562146/ref=pd_bxgy_b_img_c), which is excellent for beginners to functional programming. – Inaimathi Mar 08 '11 at 16:57
  • @Inaimathi you can put it in a new answer :) you'll get more rep for that – Mahmoud Hossam Mar 08 '11 at 17:02
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.

Jetti
  • 5,163
  • 2
  • 26
  • 41
  • Recommending lambda calculus here is like recommending electrical engineering in order to learn programming in general. –  Mar 08 '11 at 16:20
  • 1
    @delnan, functional programmin *is* lambda calculus. You can't learn one without another. – SK-logic Mar 08 '11 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.). –  Mar 08 '11 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. – SK-logic Mar 08 '11 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!). –  Mar 08 '11 at 16:41
  • @delnan, lists in Lisp and lists in Haskell are completely different beasts. It can be very confusing if you're fist exposed to lists, types, implicit currying, etc., and only then get a basic theory. Lambda calculus is tiny and beautiful, and that's exactly the reason why all the functional languages are built upon it. So there is no point in not learning it first. – SK-logic Mar 08 '11 at 17:01
  • +1 for Learn you an Erlang. I found learning some lambda calculus very helpful for understanding _OO_, never mind FP - in particular, Smalltalk's Boolean logic is implemented using Church booleans. – Frank Shearar Mar 08 '11 at 17:02
  • @Jetti, I read a bit about Erlang. Seems to be awesome, but in one of my readings I found that Erlang is not purely functional. Am I wrong? – Herberth Amaral Mar 08 '11 at 18:36
  • @Herberth Amaral - http://stackoverflow.com/questions/2271417/is-erlang-really-a-functional-language should be able to answer that question better than I can. – Jetti Mar 08 '11 at 18:41
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.

CodexArcanum
  • 3,421
  • 21
  • 23
  • 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! – Herberth Amaral Mar 08 '11 at 18:32
  • F# is not like OCaml. Even though you can write simple programs that compile under both. – lukstafi Jun 18 '13 at 11:23
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..

Mongus Pong
  • 1,418
  • 9
  • 13
  • 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. – Inaimathi Mar 08 '11 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. – Herberth Amaral Mar 08 '11 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).

Inaimathi
  • 4,884
  • 1
  • 26
  • 34
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."

SK-logic
  • 8,497
  • 4
  • 25
  • 37
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.

Ciaran
  • 216
  • 1
  • 2
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.

Abbafei
  • 821
  • 6
  • 17