Suggestions for intro to functional programming
September 30, 2014 5:02 PM   Subscribe

I’m looking for a great, homey-but-mathematically sophisticated introduction to Functional Programming book / doc / etc. Don’t mind much what language. (Swift is my primary interest, but realize this is unlikely.)

I’ve got a pretty reasonable general math background. (5 years of grad school in a non-CS but mathy field.) Mainly an iOS / Objective-C dev these days. Mostly this interest is due to Swift, but frankly like everyone+dog I’ve been chafing a bit at OO in general. (Annoyed by conflation of type and capability in traditional OO inheritance, too much mutability, too much state, not enough reasoning about data flows, etc.) That said, not really trying to learn Category Theory / Type Theory from the ground up.

(Am familiar with the book the objc.io folks are writing. Looking I guess for something a bit deeper.)
posted by ~ to Computers & Internet (11 answers total) 19 users marked this as a favorite
 
Best answer: Learn You a Haskell is a great and friendly intro to FP through Haskell. It gets into mathier things later, like functors, monoids, and monads.

I'm not sure exactly how mathy you want it. FP can get very mathy (see Edward Kmett and sigfpe's stuff) or it can stop at combinators (map, fold, etc.) and monads.
posted by glass origami robot at 5:21 PM on September 30, 2014 [3 favorites]


Best answer: Martin Odersky designed Scala and runs a really excellent course on Coursera. The class is more about the thought process behind and principles of functional programming than about Scala, per se.
posted by a lungful of dragon at 5:27 PM on September 30, 2014


Best answer: The Little Schemer might be what you're looking for.
posted by mr vino at 6:12 PM on September 30, 2014


Learn You a Haskell was also adapted for Erlang as Learn You Some Erlang. (The best-known things I can think of written in Erlang are Basho's Riak key-value store and RabbitMQ)

Clojure Koans are intended for learning Clojure, of the LISP family. (Apache Storm is written in Clojure)
posted by mkb at 6:16 PM on September 30, 2014


Do you care about the type system?

If you're okay with dynamic typing, Structure and Interpretation of Computer Programs is the best intro book I've read yet. If you prefer a more project-based approach, Siebel's Practical LISP uses a series of reasonably meaty projects to introduce the more distinguishing features LISP (macros, conditions, CLOS).

If you're curious about System F types and static type analysis, Real World OCaml or Learn You a Haskell For Great Good are both good tour-of-the-language kind of introductor books. For a more project-based approach, try Write Yourself a Scheme in 48 Hours, which uses Haskell to implement a Scheme interpreter.

Or if you just want to bend your mind right away, try Purely Functional Data Structures, Pearls of Functional Algorithm Design, or Functional Pearls (the last is a series of papers, not a book).

Most of the things I've mentioned are available full-text for free online.
posted by d. z. wang at 8:46 PM on September 30, 2014 [1 favorite]


Best answer: The Haskell Road to Logic, Maths and Programming
posted by jingzuo at 9:37 PM on September 30, 2014


I've done the Coursera class on Scala; it's pretty good.
posted by matildaben at 10:36 PM on September 30, 2014


Alongside whatever book or tutorial you choose, I'd strongly recommend watching Rich Hickey's talks, pretty much in the order presented here. He has a top-notch ability to explain the purpose and mechanics behind functional programming and higher-order functions. In a similar vein, you might find the SICP lectures useful, though they start a little slow with regards to FP-specific material.

I found SICP in emacs and making toy projects in Clojure to be a fine intro to FP. I found the most important part was rapidly iterating the creation/feedback loop, so that I wouldn't go too far down any non-idiomatic paths.
posted by daveliepmann at 1:35 AM on October 1, 2014


SICP, despite it's intimidating title, is very readable, and gets to the heart of fp by chapter 3 with sections 3.1.2 The Benefits of Introducing Assignment and 3.1.3 The Costs of Introducing Assignment. And as you can see it's available online.

There's a MOOC, Intro To FP, taught by Erik Meijer (who's fairly famous in some fp circles) at EdX starting in a couple of weeks. It'll be in Haskell, which is statically typed, not everyone's cup of tea, especially coming from Objective-C, but I'd argue it'll stretch your brain more. I can't vouch for the course, since it'll be the first time it's taught, but it looks promising.

++ The Little Schemer.

I've done the Coursera Odersky Scala course. It was horrible. Well, Scala's horrible. Odersky's brilliant (and seems like a great person), but the ugliness of grafting fp onto Java is just too much... horrible syntax, extraneous complications (see these talks by Rúnar Bjarnason and Paul Philips for attempts to fix that).
posted by at at 7:53 AM on October 1, 2014


Response by poster: Thanks so much for the terrific suggestions. I'm learning me as Haskell, and boy, it's great stuff. (In retrospect am definitely more interested in strongly typed languages, since I'm hoping to translate this good learning to Swift.)
posted by ~ at 4:59 PM on October 5, 2014


Response by poster: If anyone else is reading this specifically with an eye to Swift, the release version of the objc.io folks' book is really very good (I think quite a bit more so than the early releases). It also has a good "further reading" section.
posted by ~ at 5:01 PM on October 5, 2014


« Older Do you have experience?   |   Give me a re Call! Newer »
This thread is closed to new comments.