Welcome to another issue of Clojure Weekly! Here I collect a few links, normally 4/5 urls, pointing at articles, docs, screencasts, podcasts and anything else that attracts my attention in the clojure-sphere. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!
clojure.data/diff - Clojure Documentation For the unknown pearls in the standard library, this week I’d like to introduce you to clojure.data/diff. This namespace seems dedicated to diff because the other functions seem to be internal implementation details. This is a polymorphic diff that based on the input params is doing its best to return the diff as seen from both sides and the actual difference as the third part of the results. It can be used for all sort of useful stuff related to comparing data structures with a result that is easy to process.
Functional Geekery Episode 13 – Martin J. LoganFunctional Geekery | Functional Geekery This FG episode is about Erlang, sorry to file it under Clojure stuff. But it is an interesting and entertaining episode with Martin Logan, an Erlang veteran, illustrating a bit of history of the language and its community. Although Clojure doesn’t embrace the actor model as a fundamental concurrency construct, there is certainly inspiration coming from that with agents in Clojure and they both share immutability as their core principle. Also consider a quick look at Elixir, a modern take to Erlang with a more Ruby-like syntax.
Promise - Clojure Documentation Promises is another Clojure construct to help in creating powerful concurrency models. It doesn’t contain behaviour for a computation (like futures) but it is just delivered results with deliver. Promises are often found in conjunction with futures since the behave like single-entry blocking queues. The future can deliver to a promise that is passed in when the future is created and the main thread can at some point block while deref the promise. The advantage is that you don’t need to code any nasty “wait” semantic (like futures). There is also another important aspect of combining futures and promises this way: the callback fn can be generic and the result handled to the promise in-situ, creating the semantic of a synchronous call. The same happens as well in core.async, but the thread where the computation is running is non-blocking.
Dissecting Reducers - Skills Matter If you’re struggling understanding the new transducers primitives that Clojure 1.7 will be introducing, I strongly suggest you get your self familiar with Reducers first, because the implementation of the transforming reducers (map, filter etc) is exactly the same. This is also a very nice example of functional abstraction or “pattern” approach to functional programming that is worth understanding deeply. What I’ve linked here is a talk (30’) I gave last year about reducers from the point of view of functional abstractions (more than the parallelism they introduce with fold).
Some trivial examples of using Clojure Transducers - An Ostler in IT Of all the transducers buzz I’ve found around I’ve selected the following post because it’s mainly examples. Like the author of the post, I’ve also found transducers a natural evolution of reducers and after I went beyond the new lingo I felt myself home again. One important difference that you can clearly see here, is that reducers are not able to apply a pipeline of transformations without actually “reduce” the collection. The only way to achieve that effect is with “into” that uses reduce internally completely throwing away laziness. Transducers effectively abandons the intimate relationship with reduce (and fold).2 weeks ago