Better late than never, here is a quick check of some of my technical readings from last Summer. Let’s start with Functional Programming: A PragPub Anthology, by Michael Swaine and the PragPub writers.

I did not read the full book, but only the chapters I was interested in. Among the 5 different functional PLs discussed in the book–Scala, Haskell, Clojure, Elixir, and Swift (pending a single chapter on Lua)–I mostly focused on Clojure, Elixir, and Swift, knowing that I would probably never have any use of Elixir. I only went through the chapters about Scala. I like the way the authors lay the subject basis for the functional approach to programming when they say that it is all about functions, immutability, and above all “it’s a way of thinking.”

The choice of syntax isn’t arbitrary. It enables the most powerful metaprogramming system yet created. It’s powerful enough that the majority of the language is implemented using it. Looking at it another way, a Clojure developer has the power of a compiler writer at their fingertips.

Regarding Clojure, there is a short interview with Rich Hickey. Clojure is a LISP, so the code is data, and there is a powerful macro system under the hood. The language also features an unique approach to the concepts of identity (an entity associated with a series of values over time), value (an immutable piece of data), and state (the value of an identity at point in time), as discussed in Chapter 8. See also this presentation on identity, state and value (PDF). Persistent data structures (maps, vectors and sets) are very specific to Clojure and its way of managing concurrency1 since these entities are able to preserve their previous version where they are modified, thanks to structural sharing (provided, e.g., vectors are large enough) and “managed reference types”, which ensures that all of the references (atoms, agents, or refs) being managed point at the latest value for a given identity. For instance, when you de-reference some data from an atom, it won’t change without you knowing it or being able to return to the previous state. Chapter 9 adds further refinements to the use of agents and refs in the context of concurrent programming, considering an example of a system that keeps track of television series and episodes. While many people seem to complain about Clojure error messages and stack trace (see, e.g., Reddit, SO, or the internet to name a few threads), it has quite improved over the years, and if you are using Cider you are in good hands for a long time. In any case, Stuart Halloway describes the condition system error-type that was part of clojure-contrib and that happens to provide an way elegant logging solution.

I will probably have more to say on Clojure once I finish writing my review of Getting Clojure, by Russ Olsen.