Humble Bundle - Functional Programming: $1 (includes Introducing Elixir & Introducing Erlang)

Introducing Elixir and Introducing Erlang are currently available for $1 as part of the: Humble Book Bundle: Functional Programming

12 Likes

Nice find Chris, I’ve split your post into a separate thread so that it gets tweeted as well :023:

Anyone recommend any of the other books? I wonder if Functional Thinking, Functional JS and Becoming Functional are any good too?

1 Like

Real World Haskell is pretty great. I much prefer to it Learn You A Haskell For Great Good!. They’re probably both going to be out-relevanced and perhaps out-done by Haskell Programming because it’s more current and it’s a very real attempt at making Haskell more accessible to people.

I’ve skimmed Clojure Programming and it manages to introduce people to Lisp very concisely and then immediately get into the strong points of Clojure in the following chapters in a very efficient manner. The first chapter is essentially “Here is what makes Lisp seem weird to a Java programmer” and then there’s an introduction to functional programming which I think will serve users of “normal” FP languages in presenting “Here’s how functional programming looks and works in Lisp packaging”.

Like I said, they then follow this up with getting into the meat of Clojure and how to use it to manipulate data, as the 3rd chapter is all about collections and the great generalizations they’ve made for them, how they all work and whatnot. At the end of that chapter is a sub-chapter called Putting Clojure’s Collections to Work which includes ending up with a pretty nice set of functions for a “Game of Life” board generation using Clojure’s nice FP bits and then also doing some GUI visualization of maze generation.

I think these first chapters will in general be enough for someone to get into Clojure and then the subsequent chapters are essentially "Here’s how to continue with abstractions of different types: Macros, protocols, etc…

All in all I think Clojure Programming seems like a pretty good book for learning Clojure and understanding why you’d want to make things with it.

2 Likes

Functional JS is fantastic; personally, it’s the main reason I am where I am as a developer (Elixir programmer, & working with other functional languages on and off in my job). It’s quite old now, uses Underscore, but everything in it should still be applicable. As an introduction to FP for a JS developer, it was excellent. I think it would also be useful to a functional programmer who has managed to avoid JS, and I normally recommend it to people just learning JS who have gone past the basics. I found it very readable and extremely practical, very well paced. Michael Fogus is a good writer; I keep meaning to read his “Joy of Clojure” book but haven’t got round to it - his other writings are excellent

2 Likes

If anyone is looking for FP introduction, this book has a good promise https://drboolean.gitbooks.io/mostly-adequate-guide-old/content/

Didn’t have time to read it yet, so leaving it here just as an alternative for spending $$$

1 Like

How much you can get from that will depend on if you can put up with the author’s tone: I appreciated the explanations, but I found that the writing style grated to such an extent that I gave up about halfway in. The author also produced a supporting series of videos in which stop-motion animated toys explain functional concepts, which doubles down on the tone of writing in the book (I thought it was spectacularly horrible, nails-down-a-blackboard, but others may like it??)

1 Like

Is use of Underscore not considered necessary/current now? (Asking as a novice.)

The book was published back in 2013. It is my perception that Lodash has kind of taken over - (see also lodash/fp). Ramda seems to have a following as well.

Hey Underscore, You’re Doing It Wrong!

1 Like

I recently read Parallel and Concurrent Programming in Haskell and am currently reading Programming Rust (as paperback). Both are great learning resources that are really worth your time.

1 Like

I may be digressing a bit, but I found this talk very helpful for my own thinking on functional programming, both in Elixir and Javascript:

Why Functional Programming Doesn’t Matter
Jane Street, 2017

This is a response to the John Hughes 1988 paper, “Why Functional Programming Matters”, and what he argues is important in FP:
Higher-order function
Purity
Laziness

Jane Street’s perspective on what they found important:

*More important:
Expressive static types
Higher-order types

*Good, but in moderation:
Purity

*Less important:
Laziness

1 Like

I actually find laziness harmful personally, unless explicitly defined (I.E. I prefer the OCaml style laziness instead of the Haskell style laziness).

1 Like

Yeah, as @perreynders says Lodash has basically replaced Underscore. It’s a drop-in replacement though (I think everything in the book will Just Work with Lodash). In terms of it being de facto required, the language updates have definitely made it a helluva lot less necessary than it was at one time; I haven’t used it at all for a few years now. Its main advantage I guess is that many functions work on objects as well as arrays, which is nice. JS is in pretty good shape at the minute though (and will be in better shape again if the pipes and pattern matching proposals make it through)

Edit: https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore

Edit2: heh, if you fancy compiling Firefox yourself with the --enable-pipeline-operator flag, I think this works (completely untested at my end, may be syntax errors) https://gist.github.com/DanCouper/b620df1ee597ad3cb8043e222cefb647#file-parse-movie-lists-js-L25

1 Like

There is a pipeline operator flag?! :scream:

The proposal (MDN: Pipeline operator) is still at stage 1 and only targets single argument functions - requiring workarounds like this:

function double (x) { return x + x; }
function add (x, y) { return x + y; }

function boundScore (min, max, score) {
  return Math.max(min, Math.min(max, score));
}

let person = { score: 25 };

let newScore = person.score
  |> double
  |> (_ => add(7, _))
  |> (_ => boundScore(0, 100, _));

newScore //=> 57

// As opposed to: let newScore = boundScore( 0, 100, add(7, double(person.score)) )

babel-plugin-transform-pipeline

1 Like

Soo… we just need to curry everything then, right? :sunglasses:

Thank you very much for sharing the code sample.

1 Like

It works well with the partial application proposal, but I’m not sure about the syntax on partial application, especially given that the ? is proposed for optional chaining as well, and optional chaining is something I’d wager on being accepted given that it’s already in use in several other common languages (Ruby, C#, Swift). Re pipes, it’s a way off (beyond strawman, but not even draft status yet), but the TC39 process requires two compatible implementations, so fact it is already being tested in FF (albeit behind a compile-time flag), is encouraging. Note that there is also this at strawman (stage-0)

The good thing about

var street = user.address && user.address.street;

is that it acts as a speed bump, i.e. should I even be doing this? With methods this lead to the formulation of the Law of Demeter (see also Train Wreck) for method chains (not to be confused with Fluent interface).

var street = user.address?.street 

not so much. And given the lack of static typing, the naming of the example isn’t intention revealing:

var streetOrNil = user.address?.street

Just because it’s more convenient to propagate the nil value doesn’t mean the nil value has been dealt with.

5 Likes

Wow, this is a great package. Thanks for the post!

1 Like

Oh, I don’t think it’s necessarily fantastic, I just think it is something that is likely to get pushed through purely because it’s conceptually simple and allows authors to avoid some of the defensive boilerplate currently used

A post was split to a new topic: Humble bundle with 19 PragProg books!