Ask HN: The best plan to learn the functional programming paradigm
I have enough experience in programming in JAVA,PHP and JavaScript. I am curious to learn functional programming paradigm. I dont think my knowledge of FP is going to have any impact on my career in near future. I want to learn it only for the knowledge sake and who knows it might help me do my existing stuff in a better way.
I need help in preparing a plan which is something like below.
1. Which should be my first FP language ? 2. Should I start learning the languages directly or gather some mathematical background from any other source ? 3. Which should be the first book/videos I should go through ? 4. Can anyone suggest me a sample project that might help me build and apply all the concepts? When I was learning JAVA we had built a pet store and when I learned PHP I had built a social networking app.
7 comments
[ 2.7 ms ] story [ 24.5 ms ] thread1. Closures. Closures are handy for lots of things, but a lot of people (myself included) have said that they had difficulty understanding them at first. I don't know what your knowledge level is so I won't presume that you need a tutorial, but if you do, a lot of people here should be able to help.
2. Anonymous functions. You can create functions on-the-fly, you don't have to name them, then store them in a variable and call the variable.
I don't really "know" any functional programming languages, but these things are apparently common concepts in that arena, and playing around with them in a language that you're familiar with might make it easier for you.
I'd be willing to go into more detail if you'd like, or provide examples. I have tens of thousands of lines of JavaScript, and a lot of it takes advantage of JS' functional programming stuff.
I learned Lisp by building.
I recommend you build and fail and build more. You will learn a lot that way.
edit: grammar fail
You might get some ideas here: http://en.wikipedia.org/wiki/Functional_programming
However, "What's FP?" is ripe for flame wars so you may do better to ask abut languages that offer specific characteristics rather than whether or not people call it a functional programming language.
That said, I'd suggest Haskell. I mean, what the hell, might as well go hardcore. Start with Learn You a Haskell For Great Good, and/or Real World Haskell.
Both available free online, both available as for-purchase books, both well worth the money.
http://learnyouahaskell.com/chapters
http://book.realworldhaskell.org/read/
Learning the mathematical background first might be a good idea if you're a mathematician. Otherwise, getting at least some practical exposure in a language may cause the math to make more sense to you, should you decide to study it later.
For Scheme, some good books include: The Little Schemer and Structure and Interpretation of Computer Programs.
A good sample project might be to build some sort of language intepreter. For Scheme-based ideas, take a look at the book Essentials of Programming Languages. One of the early projects in that book is to build an arithmetic expression evaluator; by that point, you should be well on your way to thinking functionally.